Uncategorized

Refresh all views in database

If there are views created without SCHEMABINDING then persistent metadata for a view can become outdated because of changes to the underlying objects upon which the view depends. To update the view to the latest metadata it can be recreated or refreshed using the sp_refreshview procedure. Because views and its metadata can be nested refresh must be executed for all levels.

The following script will search for all views in the database and perform a call of sp_refreshview for each of them. Please adjust the command execution to your nesting level. Currently, it is set to three levels.