Replace '' with null using MSSQL2008
Post date: Apr 21, 2011 8:55:19 AM
Some time we add the values separated by ',' so we forced to use '' to remove null values and add it into one string.
So here i discussed to replace the empty values '' by null
declare @v1 nvarchar(100), @data_string nvarchar(max)
SET @data_string= '''name'', ''emp'','''','''''
print @data_string;
select @v1 = QUOTENAME('','''')
select @v1
set @data_string= replace(@data_string,@v1,'null')
print @data_string
'name', 'emp',null,null