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

How to fix it

  1. The message names the exact duplicate value — confirm whether it should genuinely be rejected (expected business rule) or is bad data.
  2. 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.
  3. For migrations, deduplicate the source data before import, or use MERGE / WHERE NOT EXISTS instead of blind INSERT.
  4. 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 →

Related