Pages

Mar 26, 2018

Msg 1776, Level 16, State 0, Line 7 There are no primary or candidate keys in the referenced table '' that match the referencing column list in the foreign key ''.

Error: Msg 1776, Level 16, State 0, Line 7 There are no primary or candidate keys in the referenced table '' that match the referencing column list in the foreign key ''.

This error occurred when trying to create the FK from table2 (column1) with reference to the composite Primary Key of table1 (column1,column2).

There were two SQL tables with successful FK between, I had to update the primary key of table1(column1) by adding additional column (column2) to fix the duplicate insertion issue so I did create a composite primary key (column1, column2). Now when I try to create the same FK back I have got the error.

Cause: Trying to create FK with column1 to the PK of column1,column2.

Work Around: Add column2 in table2 and create FK with the same combination of table1.



No comments: