patrickmcginnis59 10839 - Thursday, December 28, 2017 2:13 PM
That is the most complete one out of the lists as it includes definitions but doesn't have the columns.
For the foreign key columns, sys.foreign_key_columns
For primary key and unique constraint columns, sys.indexes and sys.indexes_columns I think is what I used before. I'm just too lazy to find what I used before right now so I'll wait for that superior post as well. 🙂
All I can find now is what I use to lists all the constraints by table - no columns or definitions:
SELECT
o.[name] as ConstraintName,
OBJECT_NAME(parent_object_id) AS TableName,
schema_name(o.[schema_id]) as SchemaName,
o.type_desc as ConstraintType
FROM sys.objects AS o
WHERE o.[type] IN ('D','C','F','PK','UQ')
and OBJECT_NAME(parent_object_id) like 'Your Table Name'
ORDER BY o.[type];
Sue