Many a times need arises to find all objects table depends on or is being referred. This blog will help you to find dependencies of a table in SQL Server.

This can be done using sys.sql_expression_dependencies system view and sys.dm_sql_referencing_entities system function. To get more details about these system objects refer to and

Let’s create a stored procedure referencing AdventureWorks.Person.Address table.

Let’s execute the below query and find out dependency information using sys.sql_expression_dependencies system view.

The referenced_id as the name suggest is the id of the object being referenced and the referencing_id is the referring object. A join with sys.objects gives the type of the referencing object. The output of the query is shown below

1_find dependencies of table in sql server

The other method to get same result is using the function sys.dm_sql_referencing_entities.  The object takes two arguments, the “schemaname.referenced_entity_name” the name of the referenced entity and the “referenced_class” which is the class of the referenced entity. The valid values for referenced_class are OBJECT, TYPE, XML_SCHEMA_COLLECTION and PARTITION_FUNCTION.  Execute the below query to get the dependency.

The output of the above query is self-explanatory and is shown below.

2_find dependencies of table in sql server



Ahmad Osama

Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook