SQL Server Error 2627 — Violation of PRIMARY KEY constraint
Violation of PRIMARY KEY constraint 'PK_X'. Cannot insert duplicate key in object 'dbo.X'. The duplicate key value is (...).
You tried to insert or update a row with a primary key value that already exists in the table.
Common causes
- Application-level ID generation racing with concurrent inserts (two processes generating the same "next" ID)
- Re-running an INSERT after a partial failure without checking what already committed
- ETL/import jobs re-processing the same source rows
- Identity column out of sync with actual table data (common after manual inserts with IDENTITY_INSERT ON)
How to fix it
- The error message itself tells you the duplicate key value — start there.
- Check for concurrent processes generating IDs outside of an IDENTITY column or sequence.
- For ETL/imports, add an existence check (MERGE or WHERE NOT EXISTS) before inserting.
- If it's an identity column drift issue, reseed it: DBCC CHECKIDENT ('table', RESEED, correct_value).
Paste your full error and the insert statement here for a fix specific to your schema.
Try error explainer free →