You are currently offline, waiting for your internet to reconnect

FIX: Complex Query Containing Redundant Logic May Cause Access Violation

This article was previously published under Q232926
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 54578 (SQLBUG_70)
A complex query that includes logically redundant code may cause a handled access violation (AV) when the Query Optimizer attempts to remove the unnecessary logic at compile time.
To work around this problem, avoid using logical redundancy in complex SQL queries.
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
254561 INF: How to Obtain Service Pack 2 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.
For example, the following query can be said to contain logically redundant code:
select stor_id, isnull(isnull(qty,0),0) quantity   from pubs..sales   where ord_num = 'P3087a'				
The outer ISNULL() function is unnecessary because the nested ISNULL() will never return NULL. In fact, neither ISNULL() function is necessary because the qty column of the sales table does not permit NULL values.

The Query Optimizer in SQL Server 7.0 attempts to make queries more efficient by eliminating unnecessary logic like that shown above (a technique referred to as "Folding"). It is during this phase of optimization with a highly complex query that SQL Server may encounter the AV described in this article.

Article ID: 232926 - Last Review: 10/21/2013 22:18:44 - Revision: 2.0

Microsoft SQL Server 7.0 Standard Edition

  • kbnosurvey kbarchive kbbug kbfix KB232926