sys.sysforeignkeys (Transact-SQL)


Contains information about the FOREIGN KEY constraints that are in the definitions of tables in the database.

System_CAPS_ICON_important.jpg Important

This SQL Server 2000 system table is included as a view for backward compatibility. We recommend that you use the current SQL Server system views instead. To find the equivalent system view or views, see Mapping System Tables to System Views (Transact-SQL). This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

Applies to: SQL Server (SQL Server 2008 through current version).
Column nameData typeDescription
constidintID of the FOREIGN KEY constraint.
fkeyidintObject ID of the table with the FOREIGN KEY constraint.
rkeyidintObject ID of the table referenced in the FOREIGN KEY constraint.
fkeysmallintID of the referencing column.
rkeysmallintID of the referenced column.
keynosmallintPosition of the column in the reference column list.

Mapping System Tables to System Views (Transact-SQL)
Compatibility Views (Transact-SQL)

Community Additions