hi! i have a query like this:
SELECT Cast(Replace(room_rate2, 'US$','') as decimal) as maxRate
FROM tblrates
now why is it i received an error like this:
Error converting data type varchar to numeric.
blah blah blah is here! blah blah » Close
1 answers
It seems to be complaining that room_rate2, after removing the string 'US$', cannot be parsed to a decimal, which is odd when you were using a regex to validate it in your earlier thread.
I'd try using a string literal instead to make sure the code is working as expected:
SELECT Cast(Replace('US$ 100.89', 'US$','') as decimal) as maxRate FROM tblrates
If it is, then you need to find some way of displaying room_rate2 to see what's actually in there.
answered 2 years ago by:
17279
thanks vulpes, you gave me an idea. i have converted it to money instead of decimal. in that way it is possible to cast it.
answered 2 years ago by:
0
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!