BUG: Force Index Option Fails with Temporary Tables in St. Procs

Last reviewed: October 21, 1997
Article ID: Q175359
The information in this article applies to:
  • Microsoft SQL Server versions 6.0 and 6.5
BUG #: 16815 (6.5)
        9986 (6.0)

SYMPTOMS

If the "force index" Optimizer hint is used on a query against a temporary table, the query may fail with the following error:

   Error 308 Severity 16
   Index %s on table %s (specified in the from clause) does not exist.

This error message occurs if both of the following conditions are true:
  • The query is within a stored procedure.

    -and-

  • The temporary table was created outside that stored procedure.

Note that the stored procedure will work if it is run under the same connection it was created on. Also, if it is run successfully under the same connection it was created on, then it will always work for all connections after that.

WORKAROUND

The stored procedure runs correctly if you EXEC it in the same batch in which the stored procedure is created. However, if you execute the stored procedure from another session, it must be recompiled (as when the server restarts).

A more permanent workaround is to submit the SELECT statement within the stored procedure by using the SQL Server 6.0 EXEC feature, rather than a straight SELECT.

STATUS

Microsoft has confirmed this to be a problem in SQL Server versions 6.0 and 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: proc
Keywords : kbbug6.00 kbbug6.50 SSrvStProc kbusage
Version : WINNT:6.0 6.5
Platform : winnt
Issue type : kbbug
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.