FIX: Error message when you run a query inside a stored procedure in SQL Server 2005: "Internal query processor error" (916795)



The information in this article applies to:

  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium Based Systems

Bug #: 531 (SQL Hotfix)

SYMPTOMS

When you run a query inside a stored procedure in Microsoft SQL Server 2005, the SQL Server Optimizer may be unable to produce an execution plan. Additionally, you may receive an error message that resembles the following:
Server: Msg 8624, Level 16, State 116, Line 1
Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server 2005 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites

No prerequisites are required to apply this hotfix.

Restart requirement

You do not have to restart the computer after you apply this hotfix.

Hotfix replacement information

This hotfix does not replace any other hotfixes.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.SQL Server 2005 32-bit versions
File nameFile versionFile sizeDateTimePlatform
Hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable
Microsoft.sqlserver.replication.dll2005.90.1534.01,608,40822-Mar-200601:07x86
Microsoft.sqlserver.smo9.0.1534.01,559,25622-Mar-200601:07Not Applicable
Osql.exe2005.90.1534.051,41622-Mar-200601:06x86
Replrec.dll2005.90.1534.0781,01622-Mar-200601:07x86
Sbmsmdlocal.dll9.0.1534.015,597,78422-Mar-200601:07x86
Sbmsmdredir.dll9.0.1534.03,927,25622-Mar-200601:07x86
Sqlaccess.dll2005.90.1534.0349,40022-Mar-200601:07x86
Sqldiag.exe2005.90.1534.0960,21622-Mar-200601:07x86
Sqlservr.exe2005.90.1534.028,780,81622-Mar-200601:07x86
Template_hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Template_hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable
SQL Server 2005 x64 edition
File nameFile versionFile sizeDateTimePlatform
Hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable
Microsoft.sqlserver.replication.dll2005.90.1534.01,813,72022-Mar-200623:20x64
Microsoft.sqlserver.smo9.0.1534.01,551,06422-Mar-200623:20Not Applicable
Osql.exe2005.90.1534.083,67222-Mar-200623:19x64
Replrec.dll2005.90.1534.01,007,32022-Mar-200623:20x64
Sbmsmdlocal.dll9.0.1534.015,597,78422-Mar-200601:07x86
Sbmsmdredir.dl9.0.1534.03,927,25622-Mar-200601:07Not Applicable
Sqlaccess.dll2005.90.1534.0356,56822-Mar-200623:20x86
Sqldiag.exe2005.90.1534.01,127,64022-Mar-200623:20x64
Sqlservr.exe2005.90.1534.039,442,64822-Mar-200623:19x64
Template_hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Template_hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable
SQL Server 2005 Itanium-based versions
File nameFile versionFile sizeDateTimePlatform
Hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable
Microsoft.sqlserver.replication.dll2005.90.1534.02,521,81622-Mar-200605:04IA-64
Microsoft.sqlserver.smo9.0.1534.01,551,06422-Mar-200605:03Not Applicable
Osql.exe2005.90.1534.0123,09622-Mar-200605:02IA-64
Replrec.dll2005.90.1534.02,137,81622-Mar-200605:04IA-64
Sbmsmdlocal.dll9.0.1534.048,464,08822-Mar-200605:02IA-64
Sbmsmdredir.dll9.0.1534.06,073,56022-Mar-200605:04IA-64
Sqlaccess.dll2005.90.1534.0351,44822-Mar-200605:03x86
Sqldiag.exe2005.90.1534.01,637,08022-Mar-200605:03IA-64
Sqlservr.exe2005.90.1534.072,244,00022-Mar-200605:03IA-64
Template_hauresourcedb.ldfNot Applicable524,28821-Mar-200621:44Not Applicable
Template_hauresourcedb.mdfNot Applicable39,780,35221-Mar-200621:44Not Applicable

WORKAROUND

To work around this problem, rewrite the query to use a format that resembles the following example query:
SELECT *
FROM View1 V INNER JOIN Table3 T  ON V.V1C1 <= T.T3C1
LEFT OUTER JOIN Table4 ON V.V1C1 = Table4.T4C1

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

This hotfix is also included in cumulative hotfix package (build 2153) for SQL Server 2005. For more information about cumulative hotfix package 918222, click the following article number to view the article in the Microsoft Knowledge Base:

918222 Cumulative hotfix package (build 2153) for SQL Server 2005 is available

Steps to reproduce the problem

  1. Create the following four tables:
    CREATE TABLE Table1 (T1C1 int check (T1C1 > 1))
    CREATE TABLE Table2 (T2C1 int check (T2C1 > 2))
    CREATE TABLE Table3 (T3C1 int )
    CREATE TABLE Table4 (T4C1 int check (T4C1 < 1))
    
  2. Create the following view:
    CREATE VIEW View1
    AS
    SELECT T1C1 V1C1 FROM Table1 
    UNION ALL
    SELECT T2C1 V1C1 FROM Table2
    
  3. Insert data into the four tables that you created in step 1:
    INSERT INTO Table1 VALUES (2)
    
    INSERT INTO Table2 VALUES (3)
    
    INSERT INTO Table3 VALUES (1)
    INSERT INTO Table3 VALUES (2)
    INSERT INTO Table3 VALUES (3)
    
    INSERT INTO Table4 VALUES (-1)
    INSERT INTO Table4 VALUES (-2)
    
  4. Run the following query to reproduce the error message that is mentioned in the "Symptoms" section:
    SELECT *
          FROM View1 V INNER JOIN Table3 T ON V.V1C1 <= T.T3C1
    WHERE V.V1C1 NOT IN (SELECT T4C1 FROM Table4)
    

Modification Type:MinorLast Reviewed:7/26/2006
Keywords:kbfix kberrmsg kbBug kbQFE kbhotfixserver kbpubtypekc KB916795 kbAudDeveloper kbAudITPRO