Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Violation of Primary Key Constraint

Author  Topic 

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-03-03 : 11:24:08
I'm trying to insert records into a table and getting the below error and not sure how to resolve it:

Server: Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_propertyItem'. Cannot insert duplicate key in object 'propertyItem'.
The statement has been terminated.

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-03 : 11:47:51
You're trying to insert a duplicate value into your primary key. Primary keys have to be unique.
Go to Top of Page

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-03-03 : 15:18:00
That simply means that if you defined your AccountID field to be the Primary Key you can't insert two records with the same AccountId. The Primary Key has to be unique so that the system would know how to lookup a single row in that table. When you encounter that error you need to do a search against the table to see if perhaps that value has already been added.
Go to Top of Page
   

- Advertisement -