[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

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.
0
dawes4000
Asked:
dawes4000
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
declare @x varchar, @y money
select @y =123900.00
select @x = convert( varchar(100), @y)
0
 
dawes4000Author Commented:
No need to convert, only have to remove the quotes around taxrate, tax, and ordamt, otherwise they were treated as char. This explains why convert never worked.
0
 
_agx_Commented:
@dawes4000

If you were using cfqueryparam you wouldn't have to worry about this kind of problem ;-)
0
 
_agx_Commented:
... 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 :)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now