Question Locked

how do i resolve this SQL error

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
ASQL Error: '[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PK_cat_validation'. Cannot insert duplicate key in object 'dbo.cat_validation'.' SQLState='23000' SQLNativeError=2627.

3 replies

by robo_dev

Duplicate key entries can happen when you reach the upper limit of the auto increment field, so, for example, if the DIM of the primary key is tinyint, the maximum is 127

Also, if this is suddenly happening on a working database, it is a sign that the table is corrupted and must be rebuilt/restored.

by john.a.wills

Before we see that we cannot really be sure. But also look at your constraint PK_cat_validation: it may simply be that you are trying to insert with a primary key that is already there, and you should either set the value differently or use an update command instead of an insert one.

This discussion is closed to new replies.