Create sp_refreshview for all Dependent Views in SQL Server
It is required to create sp_refreshview command and update view definition for all dependent views in a SQL Server database when underlying tables or database objects has been changed.
SQL Server database administrators and T-SQL developers can run the following sql code in order to list sql views dependent on other sql objects.
Please note that the field is_schema_bound_reference is identifying that the relation between the SQL Server view and the database object is schema bounded or not. Because if sql view is schema bound created, before the underlying object is altered the SQL view should be changed. Otherwise schema bound property will not allow undelying dependent object change.
After the dependent SQL views in a SQL Server database is listed, we can call each view name within a SQL cursor and execute the system procedure sp_refreshview in order to update the definition of the view object.
The above sql script will refresh SQL Server view object definitions one by one in each step of the T-SQL cursor
SQL developers can refer to t-sql tutorial SQL Server sp_refreshview to Update View Definition for sp_refreshview procedure and to Sample SQL Cursor for SQL Server cursor syntax and usage.