BUG: SELECT INTO Temp Tables w/Identity Columns May Cause Errors

Last reviewed: February 2, 1998
Article ID: Q180102
The information in this article applies to:
  • Microsoft SQL Server, version 6.5
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 version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

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 : kbbug6.50 SSrvErr_Log SSrvLock SSrvTran_SQL
Version : WINNT: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: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.