SQL Server has an ANSI_NULLS setting that determines how NULL values are evaluated when compared to another value with the Equals (=) and Not Equal To (<>) comparison operators.
While it’s true that you can change the ANSI_NULLS setting at the session level (using SET ANSI_NULLS), each database also has its own ANSI_NULLS setting.
You can check your database to see whether its ANSI_NULLS setting is ON or OFF.
To do this with T-SQL, you can either use the sys.databases catalog view or the DATABASEPROPERTYEX() function.
Read more