Error message when you use the CREATE TABLE statement to create a temp table and you use the CREATE SCHEMA statement in the same batch in SQL Server 2005: "CREATE SCHEMA failed due to previous errors" (907864)



The information in this article applies to:

  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Workgroup
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium Based Systems
  • Microsoft SQL Server 2005 Service Pack 1
  • Microsoft SQL Server 2005 Express Edition with Advanced Services

Bug #: 20011065 (SQLBUDT)

SYMPTOMS

Consider the following scenario. In Microsoft SQL Server 2005, you use the CREATE TABLE statement to create a temp table. In the same batch, you use a CREATE SCHEMA statement. In this scenario, you receive the following error message:
Msg 2759, Level 16, State 0, Line 2
CREATE SCHEMA failed due to previous errors.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Additionally, you receive an error message that resembles the following in the Results window in Query Editor:
SqlDumpExceptionHandler: Process 52 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
For more information about how to view the SQL Server error log, visit the following Microsoft Developer Network (MSDN) Web site:

CAUSE

This problem occurs because the CREATE TABLE statement and the CREATE SCHEMA statement are in the same batch. You experience this problem when the CREATE TABLE statement creates a temp table.

WORKAROUND

To work around this problem, separate the temp table creation and the schema creation in different batches. For example, the following code example causes the problem.
CREATE SCHEMA rrr
       CREATE TABLE rrr.#ttt (c1 int)
GO
To work around this problem, change the code to resemble the following code example.
CREATE TABLE rrr.#ttt (c1 int)
GO
CREATE SCHEMA rrr
GO

STATUS

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

Modification Type:MinorLast Reviewed:7/13/2006
Keywords:kbsql2005engine kbtshoot kbbug KB907864 kbAudITPRO kbAudDeveloper