Microsoft KB Archive/152353

From BetaArchive Wiki
Knowledge Base


FIX: Select with CASE Statement Inside View Can Cause Client AV

Article ID: 152353

Article Last Modified on 10/16/2003



APPLIES TO

  • Microsoft SQL Server 6.0 Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition



This article was previously published under Q152353


SYMPTOMS

A View that has a Select statement with a CASE construct that does a sub- select with an IN clause may cause the client to access violate (AV) during a Select from the View.

The following sample is the problem View definition:

   create view MyView as
   Select   Column1, Column2=
         Case
           When SomeColumn In
            (Select  SomeOtherColumn
              From   SomeOtherTable)
             Then SomeValue
           Else Null
         End
   From  MyTable
                


A Select from MyView may cause the client to access violate.

WORKAROUND

Try to avoid the CASE construct inside a View Definition or perform some pre-processing for the CASE logic before the View Definition by using the IF-ELSE construct and Temporary Tables, and then define the View on the Temporary Table.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server versions 6.0 and 6.5. This problem has been corrected in U.S. Service Pack 1 for Microsoft SQL Server version 6.5. For more information, contact your primary support provider.

Keywords: kbbug kbfix kbnetwork kbprogramming KB152353