我有一个数据库,其中有表、过程、视图和触发器的列表。
但我想要一个查询来获取表的所有依赖项,包括引用父表的子表。
我们可以使用以下方法来检查依赖关系:
方法一:使用sp_depends
sp_depends 'dbo.First'
GO
方法二:使用information_schema.routines
SELECT *
FROM information_schema.routines ISR
WHERE CHARINDEX('dbo.First', ISR.ROUTINE_DEFINITION) > 0
GO
方法 3:使用 DMVsys.dm_sql_referencing_entities
SELECT referencing_schema_name, referencing_entity_name,
referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('dbo.First', 'OBJECT');
GO
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)