Converting Varchar to Numeric/Decimal/Float -
02-21-2006
, 11:13 AM
I'm trying to take a varchar field and convert it to
numeric/decimal/float (not sure which is the best data type). I keep
receiving an error on the conversion:
Server: Msg 8114, Level 16, State 5, Line 4
Error converting data type varchar to numeric.
This is the code I tried to use but seems to be problematic:
case when ltrim(rtrim(ltv)) <> ''
then cast(ltv as numeric(21,20))
else NULL end as ltv,
The data in the field I believe to be the issue looks like this:
5.9499999999999997E-2
It seems to be a problem with converting the scientific notation, but I
don't know how to handle that. Any ideas? |