Hi all,
is there a function in SQL Server 2005 that returns NULL [or a boolean value] if any of the arguments (of any type) is NULL, which would save me from writing IF a IS NULL OR b IS NULL OR c IS NULL ...
.
Hi all,
is there a function in SQL Server 2005 that returns NULL [or a boolean value] if any of the arguments (of any type) is NULL, which would save me from writing IF a IS NULL OR b IS NULL OR c IS NULL ...
.
No, the closest you an get is NULLIF(), but that's not what you want. I'd just stick to using the OR statement here.
Here is a moderately unpleasant way of doing it:
set ansi_nulls off
if (null in (a, b, c, d, e) print 'got a null'
set ansi_nulls on
Since NULLs propogate you could do:
(cola + colb + colc) is null
assuming all compatible data types
How about ...
SELECT
CASE WHEN NULLIF(ISNULL(@testA, 1), @testA)
+ NULLIF(ISNULL(@testB, 1), @testB)
+ NULLIF(ISNULL(@testC, 1), @testC) > 0
THEN 'Got NULL'
ELSE 'NO NULL'
END