SQL Server 2008: The columns in table do not match an existing primary key or unique constraint SQL Server 2008: The columns in table do not match an existing primary key or unique constraint sql-server sql-server

SQL Server 2008: The columns in table do not match an existing primary key or unique constraint


It means that the primary key in tblOne hasn't been properly declared - you need to go to tblOne and add the PRIMARY KEY constraint back onto it.

If you're sure that tblOne does have a PRIMARY KEY constraint, then maybe there are multiple tblOne tables in your DB, belonging to different schemas, and your references clause in your FK constraint is picking the wrong one.

If there's a composite key (which your comment would indicate), then you have to include both columns in your foreign key reference also. Note that a table can't have multiple primary keys - but if it has a composite key, you'll see a key symbol next to each column that is part of the primary key.


If you have a composite key the order is important when creating a FK, and sometimes the order is not how it is displayed.

What I do is go to the Keys section of the table1 and select script primary key as create to clipboard and then create FK using the order as shown in script


If you still get that error after you have followed all advice from the above answers and everything looks right.

One way to fix it is by Removing your Primary keys for both tables, Save, Refresh, and add them again.Then try to add your relationship again.