This is more a question satisfying my curiosity. Given the following statement:
DECLARE @result BIT SET @result = CASE WHEN NULL <> 4 THEN 0 ELSE 1 END PRINT @result
Why am I returning "1" instead of "0"
Change it to:
DECLARE @result BIT SET @result = CASE WHEN NULL IS NULL OR NULL <> 4 THEN 0 ELSE 1 END PRINT @result
Correctly returns "0"
I know that NULL comparisons can be tricky, but this specific example slipped through our code verification process.
Any clarification would be greatly appreciated.
Jim b source share