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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 convert

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-11-04 : 05:22:31
Hi,
How can I convert the following number which is in a string to decimal(15, 5)?
Is this correct please?
select convert(decimal(15, 5), '7.0146999999999996E-3')

I get this error:
Error converting data type varchar to numeric.

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-11-04 : 05:35:39
Try this..


select cast(cast('7.0146999999999996E-3' as float) as decimal(15, 5))


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-11-04 : 07:16:49
Thanks
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-11-04 : 07:25:00
quote:
Originally posted by arkiboys

Thanks



Welcome

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-11-04 : 07:26:36
Hi

what is wrong below..


SELECT CONVERT(DECIMAL(15, 5), 7.0146999999999996E-3)




-------------------------
R...
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-11-04 : 12:44:23
quote:
Originally posted by rajdaksha

Hi

what is wrong below..


SELECT CONVERT(DECIMAL(15, 5), 7.0146999999999996E-3)


Nothing, but the OP had a string.
Go to Top of Page
   

- Advertisement -