February 10, 2009 at 7:32 am
I have a filed called "amtdue" that was populated with numbers and a $ sign before it, so they came in a nvarchar. I am hoping to do some kind of math on the field - can someone help me with this?
My query looks like this:
UPDATE pharmacy SET pharmacy.HIGHCOSTCLAIM = (SELECT Count(claimfile.keyid) AS CountOfCLAIMSTS FROM claimfile WHERE pharmacy.srvprovid = claimfile.srvprovid and (Convert(Int, Convert(Numeric(25,6),claimfile.amtdue)) >=150 and Convert(Int, Convert(Numeric(25,6),claimfile.amtdue)) <=500)) WHERE (((pharmacy.HIGHCOSTCLAIM) Is Null));
I get "error converting data type nvarchar to numeric"
Thanks for any help
February 10, 2009 at 7:58 am
You'll need to perform a substring function against the data to get rid of the $ when attempting to execute the query.
Another way would be to use a computed column based upon the substring, which you could make a numeric data type, this making your query a great deal simpler.
February 10, 2009 at 8:06 am
Thank you - but I think I got something simpler, I took out the other conversion stuff and "cast as money" that field (amtdue)and it seemed to work
February 10, 2009 at 8:18 am
Nice, didn't even know that you could do that. Will remember that one for the future.
Thanks
February 10, 2009 at 10:49 am
Hi
Its not a good design to have Currency symbol as part of Amount Field. Always separate these into two different columns.
Thanks
Vijaya Kadiyala
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply