Wednesday, March 7, 2012

convert scientific notation to to decimal

I am importing a bunch of data which is all in varchar format which I cast into the relevant type on transfer to the production table. One of these columns contains decimals, but some of them are occasionally given in scientific notation (3.48E-02).
I am using

CAST (v1 AS decimal(18, 13))

to do the conversion, but that seems to be unable to handle the scientific notation. Does anyone know a way around this?Try converting to float first, like this:
CAST (CAST (v1 AS float(24)) AS decimal(18, 13))

No comments:

Post a Comment