Wednesday, March 7, 2012

Problem Creating One-To-Many Relationship

Hi guys,

I'm testing some stuff. I have two tables, table1 has a primary key and table2 only has a column. When I try to create a relationship between them, SQL Server complains.

Here's my code:

Alter Table Table1
Add Constraint FK_T1 Foreign Key (T1) References Table2(T1)

And the error:

There are no primary or candidate keys in the referenced table 'Table2' that match the referencing column list in the foreign key 'FK_T1'.

Thanks
DarkneonOK guys, I found what was wrong.

I should go and kill myself for posting this question, now that I realize how stupid it is :o

No comments:

Post a Comment