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 |
nietzky
Yak Posting Veteran
75 Posts |
Posted - 2013-05-20 : 11:38:07
|
Can someone tell me how to convert nvarchar to float or numeric when data to be converted may have .961 string, sometimes starts with "."? I am getting error when I try to convert data that comes from OPENQUERY (from Oracle box). Thank youselect CAST(AvgCPU as numeric(12,3)) - failsAvgCPU is currently stored as nvarchar(384)491.5531.91148.48535.77443.961.5544341.742.83741.778.8481.15373745.765.5246.18237.167.5125.61349.26.31245.80321.94146.5321.9096.092.63555.39347.99333.006.43533.04 |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-05-20 : 12:19:47
|
What is the error?Can you try the following:[CODE]DECLARE @val1 nvarchar(384);SET @val1 = '55.393';SELECT CAST(LTRIM(RTRIM(@val1)) as NUMERIC(12,3));[/CODE] |
|
|
nietzky
Yak Posting Veteran
75 Posts |
Posted - 2013-05-20 : 12:33:49
|
Thank you. It works now. |
|
|
|
|
|