Error: 2627 PRIMARY_KEY constraint 'PK...' Cannot insert duplicate...

  • We upgraded to a new version of our ERP software and the new version added 'Menu Config' tables. In order to speed up the 'Go Live' I had run the app before and added the records into the tables in a Test version of the data, then, during the switch over ran SQL statements to create output 'INSERT into menu_config_header...' for each of the records. After updating the database I ran the saved output statements to insert the records. All seemed to work OK.

    Now, when I run the ERP software app to add a new Menu Config (record) I get an error:

    Here's the Error Message:

    Microsoft SQL Server:2627[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PK_menu_config_header'. Cannot insert duplicate key in object 'dbo.menu_config_head

    Here's the SQL Statement:

    insert into menu_config_header ( menu_config_id, menu_config_name, is_deleted ) values ( :nNextMenuConfigID, :sMenuConfigName, 'N' )

    In SSMS I have drilled down to the indexes and clicked to Rebuild the PK... index. Still get the error message.

    Help. :w00t:

    [font="Verdana"]"The Road To Success Is Always Under Construction."[/font]

  • I found information about Reseed a SQL Servier identity column.

    In a query window:

    DBCC CHECKIDENT

    (

    menu_config_header

    , RESEED

    )

    I ran this and tried adding using the application - got the same error message.

    Dang! I was hoping this would resolve the issue.

    Still looking for help.

    [font="Verdana"]"The Road To Success Is Always Under Construction."[/font]

  • CORRECTION - I just scrutinized the table and noticed menu_config_id is NOT an Identity!

    Any suggestions where to look for the 'seed value' the app is using?

    [font="Verdana"]"The Road To Success Is Always Under Construction."[/font]

  • EdA ROC (9/20/2010)


    CORRECTION - I just scrutinized the table and noticed menu_config_id is NOT an Identity!

    Any suggestions where to look for the 'seed value' the app is using?

    I would call the vendor and research vendor's KB if they have one.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • I would call the vendor and research vendor's KB if they have one.

    Thanks. There isn't much in their KB, no hits. I have a call into their support - they don't always respond in a timely manner, so, I posted here to see if I could get a quicker solution.

    I saw a reference to pk_dtproperties and I've been poking around trying to view what's in there. No success yet, I don't know how to burrow into that part of the realm.

    [font="Verdana"]"The Road To Success Is Always Under Construction."[/font]

  • Have you validated that the variable, :nNextMenuConfigID is being incremented when you run the insert statement?

  • Issue Resolved: Customer Support got back to us and informed us about a table of 'counters' (all those Next Numbers). We updated the value and everything is OK.

    Thank you everyone for your help. Appreciate it.

    [font="Verdana"]"The Road To Success Is Always Under Construction."[/font]

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply