SQL Server engine errors
Constraint Violation
Reviewed for reference consistency: August 11, 2026
violation of a primary key or unique constraint
What 2627 Means
The 2627 error on the SQL Server engine errors indicates constraint violation — violation of a primary key or unique constraint. This typically occurs due to inserting a value that already exists in a primary key column.
Error 2627 is raised when a statement violates a PRIMARY KEY or UNIQUE constraint — the value already exists in the table. The engine cancels the offending statement and rolls it back, so duplicates never land. The message names the exact constraint, which points at the conflicting row or at an ID generator that has drifted out of sync with the table.
Technical Background
Error 2627 is the standard response when a PRIMARY KEY or UNIQUE constraint is violated. These constraints are the fundamental building blocks of relational data integrity, ensuring that each row in a table is distinguishable from every other and that no logical duplicates exist.
Unlike a simple unique index, a constraint is a formal declarative rule in the database schema. Violations of these rules always result in the immediate rollback of the offending statement to maintain the integrity of the data model.
Common Causes
- Inserting a value that already exists in a primary key column
- Violating a unique constraint defined on one or more columns
- Batch update containing duplicate records for the same key
Typical Scenarios
- Manually running an INSERT statement with an ID that is already taken
- Automated system failing to check for existing records before processing a batch
What to Know
Verification that the data being inserted does not already exist in the target table is essential. Synchronization of ID generators or sequences with actual table data prevents common collision scenarios.
Frequently Asked Questions
Common questions about SQL Server 2627 error
Generally no, as it indicates a data integrity issue or a bug in the application logic that handles data entry.
Related Errors From Other Categories
Similar error codes documented across different platforms and systems