且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在sql server中查找表的所有依赖项

更新时间:2021-07-01 22:59:29

以下是我们可以用来检查依赖项的方法:

The following are the ways we can use to check the dependencies:

方法一:使用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:使用 DMV sys.dm_sql_referencing_entities

Method 3: Using DMV sys.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