PRB: Query Testing for NULL in Access Database Does not Return Records with Jet 4.0 (237992)
The information in this article applies to:
- Microsoft Data Access Components 2.1 (GA)
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft ODBC Driver for Access 4.0
- Microsoft OLE DB Provider for Jet 4.0
This article was previously published under Q237992 SYMPTOMS
When using an SQL statement with a WHERE clause that contains a test for NULL using the = operator, records that match the query are not returned in the recordset. This happens with Jet 4.0 when using DAO, ODBC or OLE DB. Here are a few examples of such queries:
SELECT * FROM Customers WHERE region = NULL
SELECT * FROM Customers WHERE region = NOT NULL
These queries worked correctly with Jet 3.5 and returned the records as expected.
This behavior will only be exhibited on computers with MDAC 2.1 and later that have Jet 4.0 installed.
CAUSE
Jet 4.0 made some changes to the SQL syntax and is now more SQL ANSI 92 compliant than before. Especially SQL ANSI 92 NULL behavior was implemented. Also remember that the result of a Boolean expression can have three results - TRUE, FALSE and NULL (in some documents referred as UNKNOWN).
The ANSI compliant syntax for testing NULL values uses the IS keyword. Examples of queries that work are:
SELECT * FROM Customers WHERE region IS NULL
SELECT * FROM Customers WHERE region IS NOT NULL
RESOLUTION
Use the IS keyword in queries that test for NULL. This change will not break on systems with Jet 3.5 as Jet 3.5 accepted both types of queries.
STATUS
This behavior is by design.
REFERENCESFor additional information, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
236991 PRB: Unrecognized Database Format Error with Access 2000 Database
235507 BUG: DAO 3.6 Causes Debug Errors in MFC DAO Non-Unicode Builds
152021 PRB: Deleting Records Containing NULLs Using DAO
Modification Type: | Major | Last Reviewed: | 12/5/2003 |
---|
Keywords: | kbDatabase kbJET kbprb kbQFE KB237992 |
---|
|