By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

Violation of primary key constraint 'pk_persons'. Cannot insert duplicate key in obje

P: 1
Hi,Am Dennis and I interact with Sql server on my daily bases.Am currently loading my data on my sql server to be used in OPENCBS and it is working well.The problem is when I try to add a new client in OPencbs am receiving the below error
Violation of PRIMARY KEY constraint 'PK_Persons'. Cannot insert duplicate key in object 'dbo.Persons'. The duplicate key value is (122).
Oct 17 '14 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,430
The error message is fairly clear. You are trying to insert an existing value into a field that doesn't allow duplicates.
Oct 17 '14 #2

Frinavale
Expert Mod 5K+
P: 9,731
As Rabbit said, if you get this error it means that you already have a record in the table with the primary key that you are attempting to insert.

Consider trapping this error and executing an appropriate response depending on your application's rules about what to do in this case(like changing the insert into an update or deleting the existing row and inserting the one you currently have).
Oct 27 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.