FIX: DocErr: Incorrect Regarding Comparison Operators w/ NULL

ID: Q133171

The information in this article applies to:

BUG# NT: 9191 (4.21a)

SYMPTOMS

On page 368 of the Microsoft SQL Server version 4.2 "Transact-SQL Reference," it says that you can use the equal sign (=) character to check for a NULL value. However, this statement is misleading and should not be considered. The only reliable way to make comparisons with NULL values is to use the expression IS [NOT] NULL.

There are two places in the documentation (TSQL Reference, pages 39 and 369) where it states that the equal sign character should not be used to compare NULL values.

Inconsistencies may occur within stored procedures that use =NULL or !=NULL because the use of the equal sign in evaluation of NULL values is not precisely defined.

STATUS

Microsoft has confirmed this to be a problem in the documentation for Microsoft SQL Server version 4.21a. This problem was corrected in SQL Server version 6.0.

MORE INFORMATION

An inconsistency problem stems from using the following syntax in a SELECT statement within a stored procedure:

   WHERE col = NULL

ANSI X3.135-1992, Section 8.2 <comparison predicates>, General Rules 1.a pg.169 states the following:

   Let X and Y be any two corresponding <row value
   constructor elements>.
   Let XV and YV be the values represented by X and Y
   respectively.

   Case:

   a) If XV or YV is the NULL value, then 'X <comparison operator> Y' is
      unknown."

Additional query words: Windows NT equals
Keywords          : kbother SSrvDoc_Err SSrvStProc kbbug4.21a kbfix6.00 
Version           : 4.21a 6.0
Platform          : WINDOWS

Last Reviewed: May 1, 1997