Jon
Jon

Reputation: 40062

Using sys.dm_sql_referenced_entities to show on dependencies that are views

I use the following query to find dependencies on a view

    SELECT referenced_entity_name,*  FROM 
sys.dm_sql_referenced_entities ('dbo.WEB_ANALYSER', 'OBJECT')

This returns tables and views used in the View. I want the above query to only return dependencies that are views

Thanks

Upvotes: 0

Views: 2520

Answers (1)

Mikael Eriksson
Mikael Eriksson

Reputation: 138980

select referenced_entity_name, re.*
from sys.dm_sql_referenced_entities ('dbo.WEB_ANALYSER', 'OBJECT') as re
  inner join sys.views as sv
    on sv.name = re.referenced_entity_name

Upvotes: 3

Related Questions