Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 CONVERT money

Author  Topic 

__madmax__
Starting Member

31 Posts

Posted - 2004-12-09 : 07:25:23
ok, have been breaking my head over this thing for too long now :D

i have a couple of money colums in my Table and i want to insert just some numbers in to there from an .asp page. I use stored procedure so i can get the @@identity.

SP:

CREATE PROCEDURE addOrder2
(
@kid int,
@subtotaal money,
@verzendKosten money,
@grandTotal money
)
AS


set nocount on

insert into orders(
kid,
subtotaal,
verzendKosten,
grandTotal
)
values (
@kid,
@subtotaal,
@verzendKosten,
@grandTotal
)
select @@identity as orderID
GO


asp page

addOrder2 '8', CONVERT(money, '298,95'), CONVERT(money, '24'), CONVERT(money, '322,95')


so i TRY to convert the data to a MONEY type but it still says;
"Incorrect syntax near the keyword 'CONVERT'."

so what am i doing wrong... do i have to use the convert in the Stored Procedure and if so, what would be teh right syntax ?

Kristen
Test

22859 Posts

Posted - 2004-12-09 : 07:48:56
You can't have an expression in the parameter to an EXEC of an SProc :-(

Edit: SQL will hapilly [I think *] make an implicit conversion - so just passing the "string" money value as a parameter should be fine

* Money is one of the few types where SQL is very restrictive in what implicit conversions it is prepared to do. Dunno why, every tie it catches me out I always think its daft!

You could have VARCHAR parameter to your SProc instead, and then EXplicitly convert to money.


Kristen
Go to Top of Page

__madmax__
Starting Member

31 Posts

Posted - 2004-12-09 : 08:34:26
ok, i got it, guess i was a little to lazy :D



CREATE PROCEDURE addOrder4

(
@kid int,
@subtotaalRaw varchar(50),
@verzendKostenRaw varchar(50),
@grandTotalRaw varchar(50)
)
AS

DECLARE @subtotaal MONEY
SET @subtotaal = CONVERT(money, @subtotaalRaw)

DECLARE @verzendKosten MONEY
SET @verzendKosten = CONVERT(money, @verzendKostenRaw)

DECLARE @grandTotal MONEY
SET @grandTotal = CONVERT(money, @grandTotalRaw)

set nocount on

insert into orders(
kid,
subtotaal,
verzendKosten,
grandTotal
)
values (
@kid,
@subtotaal,
@verzendKosten,
@grandTotal
)

select @@identity as orderID
GO
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-09 : 09:21:35
i don't get it whay you need this conversion anyway???

your sp paramteer is money and you do:
addOrder2 '8', 298.95, 24, 322.95

where's the problem?

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -