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

ID: Q180102


The information in this article applies to:

BUG #: 17763 (6.5)

SYMPTOMS

An error 3905 or 631 can occur if both of the following conditions are true:


WORKAROUND

To work around this problem, do either of the following:


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5. This problem has been corrected in U.S. Service Pack 5a for Microsoft SQL Server version 6.5. For information about downloading and installing the latest SQL Server Service Pack, see http://support.microsoft.com/support/sql/.

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          : SSrvErr_Log SSrvLock SSrvTran_SQL kbbug6.50 kbfix6.50.SP5 
Version           : winnt:6.5
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: April 21, 1999