Search code examples
sqlsql-serverinformation-schema

Search a group of SQL Server views for tables use


I am trying to search through a group of views to see if they contain certain tables.

For example: let's say I have about 30 views and I want to see if they use this particular table. How can I go about this?

I can not think about how to do this. Anyone have any ideas that can point me in the correct direction?

We are using SQL Server Management Studio v18


Solution

  • You can select this from INFORMATION_SCHEMA.VIEWS:

    SELECT * 
    FROM INFORMATION_SCHEMA.VIEWS
    WHERE VIEW_DEFINITION LIKE '%Test%';
    

    MS SQL view