Link to home
Start Free TrialLog in
Avatar of dawes4000
dawes4000Flag for United States of America

asked on

How to convert varchar to money on sql insert

I need to convert varchar to money data type when doing a SQL insert. I'm using sql server 2000. Below is my insert statement.
INSERT INTO mast
(custno, sodate, ordate, disc, taxrate, tax, ordamt, authamt, ponum, salesmn, sostat, sono, defloc, finalized, adddatetime) VALUES     ('#qrymast.custno#','#qrymast.sodate#','#qrymast.ordate#','#qrymast.disc#','0','0','#qrymast.ordamt#','0','#qrymast.ponum#','#qrymast.salesmn#','#arguments.status#','#qrymast.sono#','#defloc#','#finalized#','#qrymast.adddatetime#')

The Insert fails on taxrate, tax, ordamt. I have tried the CONVERT function but have not been able to get it to work, and have left my attempts out of this post only to keep it brief.
Avatar of Aneesh
Aneesh
Flag of Canada image

declare @x varchar, @y money
select @y =123900.00
select @x = convert( varchar(100), @y)
ASKER CERTIFIED SOLUTION
Avatar of dawes4000
dawes4000
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@dawes4000

If you were using cfqueryparam you wouldn't have to worry about this kind of problem ;-)
... I think I submitted that last comment via "SUBMIT" and not "OBJECT".   But in case I didn't, to any mods:  No, I don't have any objection :)