T-SQL Tutorial

List table constraints T-SQL


List table constraints Example

To list table constraints, use select on sys.foreign_keys, sys.key_constraints or sys.all_objects.

sys.foreign_keys

SELECT * FROM sys.foreign_keys;

sys.key_constraints

SELECT * FROM sys.key_constraints;

sys.all_objects

SELECT * FROM sys.all_objects
WHERE TYPE IN ('F','PK')
ORDER BY create_date DESC;