SQL Server查看哪些表的外键引用了某表的字段
作者:韩明剑
时间:2021-05-10
浏览:466
点赞:0

概述:本文类似工具,直接复制代码并将'被引用的表名'修改位需要查看的表名即可查看哪些表的外键引用了此表的字段

代码:

select fk.name,fk.object_id,OBJECT_NAME(fk.parent_object_id) as referenceTableName
from sys.foreign_keys as fk
join sys.objects as o on fk.referenced_object_id=o.object_id
where o.name='被引用的表名'

原创不易,转载请保留本站版权。