Refreshing user views

Synergetic use the sp_refreshview to update all standard views as part of every upgrade.

However we don't do this for user views as they may be written in such a way as to cause our database patcher to fail.

This can happen when a view is written using a SELECT * rather than explicit field names, or where a view references base tables or fields that no longer exist.

If required, you can run the following script to refresh views on an as-required basis. However we recommend re-writing any views to make them explicit in what they return.

----------------------------------------------------------------------------- -- REFRESH ALL VIEWS ----------------------------------------------------------------------------- SET NOCOUNT ON DECLARE @SQL varchar(max) = '' SELECT @SQL = @SQL + 'print ''Refreshing --> [' + name + ']'' EXEC sp_refreshview [' + name + ']; ' FROM sysobjects WHERE type = 'V' and name like 'uv%' --< condition to select all views, may vary by your standards EXEC(@SQL) GO