I want to check if @a is different from @b in the "ansi_nulls off":
set ansi_nulls off
declare @a int = 1;
declare @b int = null;
select case when @a<>@b then 'diff' else 'equal' end '@a=@b ?' --RETURNS 'diff'
but without using "set ansi_nulls off". I came up with the following, but it's quite verbose:
select
case
when @a is null and @b is not null then 'diff' -- null x
when @a is not null and @b is null then 'diff' -- x null
when @a is null and @b is null then 'equal' -- null null
when @a <> @b then 'diff' -- x x
else 'equal'
end
is there a shorter way of doing this? Thanks, Nestor