Understanding nulls in SQL Server 7.0

 

By default, SQL Server configures your server to not support ANSI nulls. With this default setting, you can  construct a query that evaluates whether or not a column is equal to null. This means that if you issue the following query against the pubs database, you will see rows in the result set: 

 

SELECT * FROM titles WHERE price = NULL

 

Note: If your server isn't using the default setting for nulls, use the following query instead:

 

SET ANSI_NULLS OFF

SELECT * FROM titles WHERE price = NULL

 

In contrast, you will not see any rows in the result set if you run the following query:

 

SET ANSI_NULLS ON

SELECT * FROM titles WHERE price = NULL

 

In the ANSI null specification, if a column has a null value, the column cannot be evaluated in a conditional statement. Thus, nothing can be equal to null-not even null itself. 

 

  

SQL Index

Main Index

Search RD Techbase