Find all references to an object in an SQL Server database

后端 未结 10 1683
深忆病人
深忆病人 2020-12-13 10:02

I\'m trying to find all references to an object in an SQL Server database.

How can I quickly search? SQL Server Management Studio does not seem to do it. I use http:

10条回答
  •  醉梦人生
    2020-12-13 10:29

    Very late to the party, but...

    You can use the system proc sys.sp_depends:

    exec sys.sp_depends 'object_name'
    

    The result is a table listing all of the database objects that depend on (i.e., reference) object_name. Each row contains the name and type of the referring object, along with other info columns, depending on the type of object_name.


    Note: This proc was added in MS SQL Server 2008.

    See: MSDN docs

    The docs say that this proc may be removed in a future release, and to use sys.dm_sql_referencing_entities instead, but it's still alive and kicking in MS SQL 2017.

提交回复
热议问题