Microsoft KB Archive/279319

From BetaArchive Wiki
Knowledge Base


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

Article ID: 279319

Article Last Modified on 3/14/2006



APPLIES TO

  • Microsoft SQL Server 7.0 Standard Edition



This article was previously published under Q279319

BUG #: 57966 (SQLBUG_70)

SYMPTOMS

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

CAUSE

The query caused a handled exception in SQL Server, and the process was stopped.

WORKAROUND

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 value2
END
                

Can be rewritten as:

CASE
   WHEN (SELECT COUNT(1) FROM T2 WHERE T1.F1 = T2.F2) > 0 THEN value1
   ELSE value2
END
                

STATUS

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.


Additional query words: Query Processor Exception AV sqlserver

Keywords: kbbug kbfix KB279319