Microsoft KB Archive/180102

= FIX: SELECT INTO Temporary Tables with Identity Columns May Cause Errors =

Article ID: 180102

Article Last Modified on 3/14/2006

-

APPLIES TO


 * Microsoft SQL Server 6.5 Standard Edition

-



This article was previously published under Q180102



BUG #: 17763 (6.5)



SYMPTOMS
An error 3905 or 631 can occur if both of the following conditions are true:
 * SELECT INTO is used to create temporary tables against tables with identity columns in a user-defined transaction.

-and-
 * A table with an identity column is updated.



WORKAROUND
To work around this problem, do either of the following:
 * Remove the user-defined transaction and possibly use trace flag 5302 to avoid deadlocks in the tempdb database.

-or-
 * Prevent the SELECT INTO statement from creating the temporary table with the identity column. You can do this by using the CONVERT function to convert the identity column to its datatype.



STATUS
Microsoft has confirmed this to be a problem in SQL Server 6.5. This problem has been corrected in Service Pack 5a for Microsoft SQL Server 6.5.For more information, click the following article number to view the article in the Microsoft Knowledge Base:

197177 INF: How to Obtain SQL Server 6.5 Service Pack 5a

For more information, contact your primary support provider.



MORE INFORMATION
The following are the errors that would normally be seen in the SQL Server errorlog when this problem occurs:

Error : 631, Severity: 21, State: 1

The length of 35 passed to delete row routine for the row at offset 1946 is incorrect on the following page: Page pointer = 0x1016800, pageno = 319, status = 0x111, objectid = 3, indexid = 0

Error : 602, Severity: 21, State: 3

Could not find row in Sysindexes for dbid '2', object '1655676946',index '-1'. Run DBCC CHECKTABLE on Sysindexes.

or

Error : 3905, Severity: 21, State: 2

Can't unsplit logical page 316 in object 'syscolumns' in database 'pubs' - row number 12 is used on both pages.

Error : 602, Severity: 21, State: 3

Could not find row in Sysindexes for dbid '2', object '98099390',index '-1'. Run DBCC CHECKTABLE on Sysindexes.

Normally in this situation, the locks held by the client that caused the error will not be cleaned up, and will still show in the sp_lock stored procedure with a spid of -1. When this problem occurs, clients are unable to create temporary tables, and you can only stop the SQL Server with the SHUTDOWN WITH NOWAIT Transact-SQL statement.

The following is an example of how to avoid the temporary table being created with the identity column property: CREATE TABLE x (a int identity(1,1), b int) GO CREATE PROCEDURE sp_selectintoidentity AS SELECT Convert(int, a), b INTO #temp FROM x RETURN GO

Additional query words: syscolumns 602

Keywords: kbbug kbfix KB180102

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.