views:

654

answers:

1

I have two tables one has a three column composite key. The other needs to reference this composite key.

What is the syntax for creating a foreign key which references multiple columns.

I tried googleing, but I couldn't find it.

+6  A: 
FOREIGN KEY (col1, col2, col3) REFERENCES ParentTable (colA, colB, colC)

Look under "<table_constraint>" in the online docs for Microsoft SQL Server CREATE TABLE.

Bill Karwin