Article ID: 290915 - Last Review: October 31, 2003 - Revision: 3.2 FIX: CREATE for Existing Object with IDENTITY Column Causes Duplicate IDENTITY ValuesThis article was previously published under Q290915
BUG #: 54428 (SQLBUG_70) BUG #: 201136 (SHILOH_bugs) On This PageSYMPTOMS
When a CREATE statement fails due to the object already existing, and one of the columns has the IDENTITY property, duplicate IDENTITY values may result. If there is a unique index or primary key on the table, subsequent inserts will fail with a "duplicate key" message.
CAUSE
The IDENTITY value is incorrectly set when a CREATE statement fails due to the object already existing.
RESOLUTIONSQL Server 2000To 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
(http://support.microsoft.com/kb/290211/EN-US/
)
INF: How to Obtain the Latest SQL Server 2000 Service Pack
SQL Server 7.0To resolve this problem, obtain the latest service pack for SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:301511
(http://support.microsoft.com/kb/301511/EN-US/
)
INF: How to Obtain the Latest SQL Server 7.0 Service Pack
WORKAROUND
To work around this problem, you can do the following:
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. SQL Server 2000This problem was first corrected in SQL Server 2000 Service Pack 1.SQL Server 7.0This problem was first corrected in SQL Server 7.0 Service Pack 1.MORE INFORMATION
To reproduce the problem, run the following query multiple times:
Server: Msg 2627, Level 14, State 1, Line 1 Violation of PRIMARY KEY constraint 'PK1'. Cannot insert duplicate key in object 'Table1'. The statement has been terminated.
| Article Translations
|
Back to the top
