Table and Column Level Referential Integrity Constraints

You can define referential integrity constraints at the column level or the table level.

When you define table-level referential integrity constraints, include the foreign key clause, and a list of one or more column names. foreign key specifies that the listed columns in the current table are foreign keys for which the target keys are the columns listed the following references clause. For example:

constraint sales_detail_constr
     foreign key (stor_id, ord_num)
     references my_salesdetail(stor_id, ord_num)

The foreign key syntax is permitted only for table-level constraints, and not for column-level constraints.

After defining referential integrity constraints at the column level or the table level, you can use sp_primarykey, sp_foreignkey, and sp_commonkey to define the keys in the syskeys system table.

Note: The maximum number of references allowed for a table is 192.
Related concepts
Table and Column Level Constraints