Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Unique constraint and Foreign key

$
0
0
Just wondering.....One of our developers just steped into our office and asked why it is not possible to create a Foreign key to a Unique constraint ??Explanation on this;Table A has column 1 holding a Primay key and two columns (2 and 3) holding a Unique combination (and some more columns).He created an Unique constraint on column 2 and 3 together.He wanted to use this Unique combination to point to table B (instead of the table 1's PK)so he tried to create a foreign key on a column in table B but an error popped up prompting;[b]The columns in table 'TABLE_A' do not match an existing primary key or UNIQUE constraint.[/b]Ok - these two columns ar no PK but the hold an Unique constraint......Can anyone explain why this error popped up or how to solve this?Regrads,GKramer

Viewing all articles
Browse latest Browse all 3145

Trending Articles