What does SET ANSI_NULLS OFF
do?
SET ANSI_NULLS OFF
instructs the server to evaluate statements involving NULL
using non-standard semantics.
SET ANSI_NULLS OFF;
SELECT CASE WHEN NULL = NULL THEN 1 ELSE 0 END; -- Evaluates to 1 (bad!)
SET ANSI_NULLS ON;
SELECT CASE WHEN NULL = NULL THEN 1 ELSE 0 END; -- Evaluates to 0 (good!)
You should never create new code with with the non-standard semantics setting of SET ANSI_NULLS OFF
because:
NULL
is treated differently from any other value (for instance in a WHERE
clause), values compared with NULL
should always return False / UNKNOWN,If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With