FIX: Complex Query Containing Redundant Logic May Cause Access Violation

Article translations Article translations
Article ID: 232926 - View products that this article applies to.
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)
Expand all | Collapse all

SYMPTOMS

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.

WORKAROUND

To work around this problem, avoid using logical redundancy in complex SQL queries.

STATUS

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.

MORE INFORMATION

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.

Properties

Article ID: 232926 - Last Review: October 21, 2013 - Revision: 2.0
APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbnosurvey kbarchive kbbug kbfix KB232926

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com