SQL Server Error 2601 — Cannot insert duplicate key row
Cannot insert duplicate key row in object 'dbo.X' with unique index 'IX_Y'. The duplicate key value is (...).
This is the same underlying problem as error 2627 (duplicate value), but on a unique index or unique constraint rather than the primary key — commonly things like an email address, username, or SKU column.
Common causes
- Two concurrent requests both trying to claim the same unique value (e.g. two signups with the same email racing each other)
- No existence check before insert — the application assumes the value is new without verifying
- A data migration or import introducing duplicates that violate a uniqueness rule added after the fact
- A retry mechanism resubmitting the same insert after a network blip, without idempotency handling
How to fix it
- The message names the exact duplicate value — confirm whether it should genuinely be rejected (expected business rule) or is bad data.
- For expected conflicts (e.g. email already registered), catch this specific error in the application and return a clean user-facing message rather than a raw 500.
- For migrations, deduplicate the source data before import, or use MERGE / WHERE NOT EXISTS instead of blind INSERT.
- For race conditions, consider a proper existence check inside the same transaction, or handle the exception rather than trying to prevent it with a pre-check (which itself can race).
Paste your error and insert statement here for a fix specific to your schema.
Try error explainer free →