Monday, September 14, 2015

Cannot insert duplicate key row in object 'dbo.IV00101' with unique index 'AK7IV00101'.

Problem
Cannot insert duplicate key row in object 'dbo.IV00101' with unique index 'AK7IV00101'. The duplicate key value is (               , 8).

8 = DEX_ROW_ID. I can see that there is already a record in the table with DEX_ROW_ID=8. Why is the identity column trying to reused a number?!

Solution
DBCC CHECKIDENT ('IV00101', NORESEED);
This was showing: "Current identity = 8. Current column value = 2200"

So I reseeded the identity to 2201.

DBCC CHECKIDENT ('IV00101', RESEED, 2201);

After doing this i was able to insert records into IV00101 again.

Refhttp://blog.sqlauthority.com/2013/05/08/sql-server-reseed-identity-in-table-column-rest-table-identity-value-sql-in-sixty-seconds-051/ 

No comments:

Post a Comment

There was an error in this gadget