Cannot insert duplicate key row in object with unique index on duplicate foreing key

  • looks like there is a constraint to not allow duplicates in the table that is referring to fk_mfg_nb in your output in your comment, its a unique index so thus its not allowing another 64 in that column in that table, if it were 65 that you were inserting it would allow it...option is to include another column that will make it unique or change the value to 65 to have the ability to insert it

  • Can't change the value to 65 as it's the [id] from the other table TBL_DFQ_MFG_PART_NBR. The need then is to have the field fk_mfg_nbr allow duplicates.

  • Turns out that SQL Server, by default, sets indexed fields to allow only unique values. To check this, open the table in Design and select "Manage Indexes and Keys" option. Select the index/key listed and check the appropriate Yes/No drop down for the "Is Unique" property.

  • The change of a unique to non-unique index means changing the business logic, so make a double check if you're going with this.

    Igor Micev,My blog: www.igormicev.com

  • Noted. In this case, it's a standard Foreign key relationship, like having the id from a country table as a fk in an address table.

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

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