Lesson 11
Using Views to Show Information
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.
Question: Is it possible to get a list of all the views in a database that use a certain table?
Solution 1:
SELECT *
FROM INFORMATION_SCHEMA.VIEWS
WHERE VIEW_DEFINITION like '%[YourTableName]%'
Solution 2:
SELECT * FROM INFORMATION_SCHEMA.VIEWS
WHERE VIEW_DEFINITION
like '%YourTableName.%' OR
VIEW_DEFINITION like '%YourTableName]%' OR
VIEW_DEFINITION like '%YourTableName %'