I want to check if @a is different from @b in "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 ?'
but without using "set ansi_nulls off". I came up with the following, but it is pretty 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 to do this? Thanks, Nestor
source
share