Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi, i have values like this -1.45000001339213E-06 in the column defined as float. I want to be able to exclude or truncate the E-06 part of the value. when i try cast it give me the error 'Arithmetic overflow error converting float to data type numeric'. Round also does not work. How can i do it?Thanks
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-01-24 : 11:38:59
How are you trying to truncate it? "Truncate" may be a misnomer - you can express the same number in other formats. For example see the code below. Also, float is an approximate representation, so the result you get back may not be exactly the same
create table #tmp(floatval float);insert into #tmp values ('-1.45000001339213E-06');select cast(floatval as decimal(19,16)) from #tmpdrop table #tmp;