I have a varchar value that needs to be casted into a money value. Tee value I like to cast looks like this:
I thought this should work
select
cast(replace([Gross value transactions], '$','')as numeric) as amount
from xy
I get the following error:
Error converting data type nvarchar to numeric.
Is this because of the commas and dots? Like in $2,535,000.00? How do I get rid of this? Can I directly cast it as money?
@Thom A I tried actually to cast it into money directly:
,cast([Gross value transactions] as money) as amount
I got the following Error Message: Cannot convert a char value to money.
Not much more luck with this:
,cast(replace(replace(replace([Gross value transactions (NZD)], '$',''), ',',''), '.','') as numeric) as amount
Error converting data type nvarchar to numeric.
How can I cast it sucessfully?