Tuesday, March 20, 2012

Convert varchar to numeric

I have a varchar value like -2.47382558882236E-10. How can I convert this
to -2.47382558882236 in order to then convert to numeric. Logically I want
to truncate everything after the 14th digit to the right of the decimal
point.
Thanks for any help.Try,
select cast(cast('-2.47382558882236E-10' as float) as decimal(16, 14))
go
AMB
"Terri" wrote:

> I have a varchar value like -2.47382558882236E-10. How can I convert this
> to -2.47382558882236 in order to then convert to numeric. Logically I want
> to truncate everything after the 14th digit to the right of the decimal
> point.
> Thanks for any help.
>
>

No comments:

Post a Comment