declare @null varchar(1);
set @null = null;
if (@null is null)
begin
print 'is null always works not matter "ANSI_NULLS" variable ';
end
set ANSI_NULLS OFF
if (@null = null)
begin
print '= null works when "ANSI_NULLS" = OFF only';
end
set ANSI_NULLS ON
if not exists(select 1 where @null =null)
begin
print '= null not works when "ANSI_NULLS" <> OFF';
end
set @null = null;
if (@null is null)
begin
print 'is null always works not matter "ANSI_NULLS" variable ';
end
set ANSI_NULLS OFF
if (@null = null)
begin
print '= null works when "ANSI_NULLS" = OFF only';
end
set ANSI_NULLS ON
if not exists(select 1 where @null =null)
begin
print '= null not works when "ANSI_NULLS" <> OFF';
end