SELECT f.name AS ForeignKeyName, OBJECT_NAME(f.parent_object_id) AS ReferencingTable, COL_NAME(fc.parent_object_id, fc.parent_column_id) AS ReferencingColumn, OBJECT_NAME (f.referenced_object_id) AS ReferencedTable, COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS ReferencedColumn FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.object_id = fc.constraint_object_id WHERE OBJECT_NAME (f.referenced_object_id) = 'pmw_house' ORDER BY ReferencingTable, ReferencingColumn;
当你尝试截断(TRUNCATE)一个数据库表时,如果该表被其他表的 FOREIGN KEY 约束引用,你将无法执行该操作。这是因为截断表会删除表中的所有数据,并且通常也会重置表的身份标识(IDENTITY)值,这可能会破坏外键引用的完整性。
标签:referenced,NAME,object,FOREIGN,OBJECT,fc,KEY,SQL,id From: https://www.cnblogs.com/LuoCore/p/18144183