This is more of a question to satisfy my own curiosity. Given the following statement:
DECLARE @result BIT
SET @result = CASE WHEN NULL <> 4 THEN 0
ELSE 1
END
PRINT @result
Why do i get back "1" instead of "0"
Changing it to:
DECLARE @result BIT
SET @result = CASE WHEN NULL IS NULL
OR NULL <> 4 THEN 0
ELSE 1
END
PRINT @result
Correctly gives me back "0"
I know NULL comparisons can be tricky, but this particular example slipped through our code review process.
Any clarifications would be greatly appreciated