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 trouble converting a text field into decimals in a select statement.The select statement is as follows:select cast(ltrim(rtrim(units)) as decimal) as unitsand I get an error message:Msg 8114, Level 16, State 5, Line 23Error converting data type nvarchar to numeric.and the 'units' column contains ' 324,32 'Can anyone help?many thanks,jay
bitsmed
Aged Yak Warrior
545 Posts
Posted - 2014-07-05 : 12:56:56
You probably need to replace the comma to period:
select cast(ltrim(rtrim(replace(units,',','.'))) as decimal) as units