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 database that use a certain table?
If you need to find database objects (e.g. tables, columns, triggers) by name - have a look at the FREE Red-Gate tool called SQL Search which does this - it searches your entire database for any kind of string(s).
To find all of the SQL Server database views where a table is used, just apply a filter criteria on table_name column of the information schema view INFORMATION_SCHEMA. VIEW_TABLE_USAGE as seen below.
This should do it:
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE VIEW_DEFINITION like '%YourTableName%'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With