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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DENNISG
    New Member
    • Oct 2014
    • 1

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

    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).
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The error message is fairly clear. You are trying to insert an existing value into a field that doesn't allow duplicates.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      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).

      Comment

      Working...