SQL中如何根据已知的主键查询所有引用这个主键的外键约束的名称
SELECT OBJECT_SCHEMA_NAME(parent_object_id) AS SchemaName, OBJECT_NAME(parent_object_id)
AS TableName ,Name
FROM sys.foreign_keys WHERE referenced_object_id=OBJECT_ID('dbo.Table1')
其中Table1是需要查询的表
SELECT OBJECT_SCHEMA_NAME(parent_object_id) AS SchemaName, OBJECT_NAME(parent_object_id)
AS TableName ,Name
FROM sys.foreign_keys WHERE referenced_object_id=OBJECT_ID('dbo.Table1')
其中Table1是需要查询的表