sql server - T-SQL converting string into float -
in stored procedure on sql server, trying convert values varchar column float format. values varchar column numbers sign @ beginning , '.' before decimals.
examples: '+0000000000000044.09' or '-0000000000114995.61'
if try this: convert(float,mystring), doesn't work. have: error converting data type varchar float
please tell me if possible kind of conversion. or there way convert string sign , '.' float?
thank you, nello
as examples both work, i'd guess there's value somewhere in table that's causing problem. in recent versions of sql server (2012 onwards), try_convert
function can useful tracking down kind of issue.
try_convert
not throw exception on conversion failure, instead return null value, can figure out values causing problem this:
select * your_table try_convert(float, your_column_name) null
if rows returned, rows problem values can't converted float.
Comments
Post a Comment