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.
| 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 canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2009-11-04 : 07:16:49
|
| Thanks |
 |
|
|
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 canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-11-04 : 07:26:36
|
| Hiwhat is wrong below..SELECT CONVERT(DECIMAL(15, 5), 7.0146999999999996E-3)-------------------------R... |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-11-04 : 12:44:23
|
quote: Originally posted by rajdaksha Hiwhat is wrong below..SELECT CONVERT(DECIMAL(15, 5), 7.0146999999999996E-3)
Nothing, but the OP had a string. |
 |
|
|
|
|
|