FIX: Stored Procedure That Creates Temp Table [#a.b.c.d.e] Causes Access Violation (308817)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q308817
BUG #: 354434 (SHILOH_BUGS)

SYMPTOMS

The execution of a stored procedure that creates a temporary table with one of the following name patterns, which also deletes or selects data from the temporary table, may cause an Access Violation:
   Table Name: #a.b.c.d.e

   -or-
 
   Table Name: #f.

   Where a, b, c, d, e, f can be any combination of characters that 
   result in a valid identifier or an empty string, and the table 
   name can be delimited by double quotes (" ") or brackets ([ ]).
				
In other words, the problematic temporary table name ends in a dot ".", or contains four or more dots.

CAUSE

A table name that follows one of the name patterns described in the "Symptoms" section does not comply with the rules for the format of regular identifiers and must be delimited. Delimited identifiers are either enclosed in double quotation marks (" ") or brackets ([ ]).

For temporary tables created in a stored procedure that follow one of the name patterns described in the "Symptoms" section, SQL Server does not correctly interpret the table name handed over to the query processor because the query tree removes the delimiters that enclose the temporary table name.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

WORKAROUND

To work around this problem, modify the temporary table name so that it does not contain four dots "." and so that it does not end in a dot.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was first corrected in Microsoft SQL Server 2000 Service Pack 2.

MORE INFORMATION

The following two sample stored procedures cause the Access Violation:

CREATE PROCEDURE Sample1
AS
   CREATE TABLE "#a.b.c.d.e"
      ( col1 int)
   SELECT * FROM "#a.b.c.d.e"
GO


CREATE PROCEDURE Sample2
AS
   SELECT 1 AS Col1 INTO [#f.]
   DELETE [#f.]
GO
				
NOTE: The access violation does not occur if you remove the Transact-SQL statements from the stored procedures and you execute the Transact-SQL statements directly in Query Analyzer.

The following short stack dump appears in the SQL Server error log:
-------------------------------------------------------------------------------
Short Stack Dump
005B1538 Module(sqlservr+001B1538) (CTableVariableManager::GetTableVariableId+0000002A)
006C55CB Module(sqlservr+002C55CB) (CTableAlias::GetExecIds+00000091)
004970D6 Module(sqlservr+000970D6) (CQScanTableScan::CQScanTableScan+0000004A)
00497067 Module(sqlservr+00097067) (CXteTableScan::QScanGet+00000089)
00427ACB Module(sqlservr+00027ACB) (CXteProject::QScanGet+00000092)
004241A1 Module(sqlservr+000241A1) (CQueryScan::CQueryScan+00000288)
00423F91 Module(sqlservr+00023F91) (CQuery::Execute+0000006A)
00418D3E Module(sqlservr+00018D3E) (CStmtQuery::ErsqExecuteQuery+0000022C)
00430962 Module(sqlservr+00030962) (CStmtSelect::XretExecute+0000020B)
00413CEE Module(sqlservr+00013CEE) (CMsqlExecContext::ExecuteStmts+000002D2)
004133E9 Module(sqlservr+000133E9) (CMsqlExecContext::Execute+000001B6)
00412918 Module(sqlservr+00012918) (CSQLSource::Execute+00000331)
004E737F Module(sqlservr+000E737F) (CStmtExec::XretLocalExec+0000014D)
004E721B Module(sqlservr+000E721B) (CStmtExec::XretExecute+0000031A)
00413CEE Module(sqlservr+00013CEE) (CMsqlExecContext::ExecuteStmts+000002D2)
004133E9 Module(sqlservr+000133E9) (CMsqlExecContext::Execute+000001B6)
00412918 Module(sqlservr+00012918) (CSQLSource::Execute+00000331)
00448916 Module(sqlservr+00048916) (language_exec+000003E1)
00411D4C Module(sqlservr+00011D4C) (process_commands+000000E0)
41073379 Module(UMS+00003379) (ProcessWorkRequests+0000024A)
41073071 Module(UMS+00003071) (ThreadStartRoutine+000000BD)
7800A27B Module(MSVCRT+0000A27B) (beginthread+000000CE)
77E8758A Module(KERNEL32+0000758A) (SetFilePointer+0000018A)
				

Modification Type:MajorLast Reviewed:10/17/2003
Keywords:kbbug kbfix KB308817