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.

Leave a Comment