When the Microsoft SQL Server driver establishes a connection, the driver sets the Microsoft SQL Server database option ansi_nulls to on. This action ensures that the driver is compliant with the ANSI SQL standard, which makes developing cross-database applications easier.
By default, Microsoft SQL Server does not evaluate null values in SQL equality (=) or inequality (<>) comparisons or aggregate functions in an ANSI SQL-compliant manner. For example, the ANSI SQL specification defines that
col1=null as shown in the following Select statement always evaluates to
false:
Setting ansi_nulls to on changes how the database handles null values and forces the use of
IS NULL instead of
=NULL. For example, if the value of col1 in the following Select statement is null, the comparison evaluates to true: