Consider the following TSQL code:
declare @a nvarchar(500) = N''
select try_convert(float, @a)
The output is:
0
I need the output to be NULL.
I can do this:
declare @a nvarchar(500) = N''
select case @a
when '' then null
else try_convert(float, @a)
end
and it works just fine.
However, this is just a mock-up. In my real life scenario, instead of @a, there are over 200 NVARCHAR(500) columns, either floats or zero length strings. I need a quick way of converting zero-length strings to NULL (and everything else to float), possibly without having to build 200 separate CASE statements.
varchartoint.