FIX: Query Using Nested IN and a CASE Clause Causes an Access Violation

This article was previously published under Q279319
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 57966 (SQLBUG_70)
Running a query with two or more nested IN clauses and a CASE statement may cause the connection to be broken and the following error to be returned:
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.Connection Broken
The query caused a handled exception in SQL Server, and the process was stopped.
To work around this problem, replace the IN clause with a SELECT COUNT(1) > 0 statement. For example, part of the query that looks like the following:
CASE   WHEN T1.F1 IN (SELECT T2 FROM T2) THEN value1   ELSE value2END				
Can be rewritten as:
CASE   WHEN (SELECT COUNT(1) FROM T2 WHERE T1.F1 = T2.F2) > 0 THEN value1   ELSE value2END				
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
274799 INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.
Query Processor Exception AV sqlserver

Article ID: 279319 - Last Review: 10/21/2013 03:44:30 - Revision: 2.1

Microsoft SQL Server 7.0 Standard Edition

  • kbnosurvey kbarchive kbbug kbfix KB279319