How to find which views are using a certain table in SQL Server (2008)?

后端 未结 7 867
孤街浪徒
孤街浪徒 2021-01-31 13:30

I have to add a few columns to a table and I also need to add these columns to all the views that use this table.

Is it possible to get a list of all the views in a data

7条回答
  •  孤街浪徒
    2021-01-31 14:09

    To find table dependencies you can use the sys.sql_expression_dependencies catalog view:

    SELECT 
    referencing_object_name = o.name, 
    referencing_object_type_desc = o.type_desc, 
    referenced_object_name = referenced_entity_name, 
    referenced_object_type_desc =so1.type_desc 
    FROM sys.sql_expression_dependencies sed 
    INNER JOIN sys.views o ON sed.referencing_id = o.object_id 
    LEFT OUTER JOIN sys.views so1 ON sed.referenced_id =so1.object_id 
    WHERE referenced_entity_name = 'Person'  
    

    You can also try out ApexSQL Search a free SSMS and VS add-in that also has the View Dependencies feature. The View Dependencies feature has the ability to visualize all SQL database objects’ relationships, including those between encrypted and system objects, SQL server 2012 specific objects, and objects stored in databases encrypted with Transparent Data Encryption (TDE)

    Disclaimer: I work for ApexSQL as a Support Engineer

提交回复
热议问题