You can check nulls with CASE WHEN (dynamic VALUES is a Postgresism, but the important part works in SQL Server too):
CASE WHEN
VALUES
SELECT CASE WHEN x IS NULL THEN 'yes' ELSE 'no' END AS is_null FROM (VALUES (true), (null)) AS a (x); is_null ───────── no yes (2 rows)
It's the CASE x WHEN ... construction that does not work, since nulls aren't equivalent to anything, even each other:
CASE x WHEN ...
SELECT CASE x WHEN NULL THEN 'yes' ELSE 'no' END AS is_null FROM (VALUES (true), (null)) AS a (x); is_null ───────── no no (2 rows)
Same in SQL Server
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can check nulls with
CASE WHEN
(dynamicVALUES
is a Postgresism, but the important part works in SQL Server too):It's the
CASE x WHEN ...
construction that does not work, since nulls aren't equivalent to anything, even each other:Same in SQL Server