Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 sys.dm_sql_referencing_entities over list of table

Author  Topic 

shiloh
Starting Member

48 Posts

Posted - 2011-08-01 : 15:13:08
Hi all

Trying to use sys.dm_sql_referencing_entities DMV to find all the dependent objects for a given table.


SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('Production.Product', 'OBJECT');

How do we use the same query over a list of tables?
I could write a loop to loop through each table in my list and run above query but hoping there must be a better way to run a join against my table (with the list of tables)..

shiloh
Starting Member

48 Posts

Posted - 2011-08-01 : 16:59:15
or, is there a better way to find all dependent objects for a given object.
For example,

If View1 references Table1 and Table2, and View2 references View2

given Table1/Table2 I need to find there are 2 dependencies - View1 and view2.
Given View1, I need to know it needs Table1, Table2 and is referenced by View2.
given View2, I need to know it needs View1, Table1 and Table2.. etc


Go to Top of Page
   

- Advertisement -