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

  • 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.
(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.
  • 2
1 Solution
Aneesh RetnakaranDatabase AdministratorCommented:
declare @x varchar, @y money
select @y =123900.00
select @x = convert( varchar(100), @y)
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.

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 :)

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