Not logged in - Login

SQL Refresh Views

The following is an example of how to refresh all the user views in a database.

DECLARE @sqlcmd NVARCHAR(MAX) = ''
SELECT @sqlcmd = @sqlcmd +  'EXEC sp_refreshview ''' + a.[name] + ''';
' 
FROM sys.objects a 
WHERE a.type = 'V' and a.is_ms_shipped = 0


print @sqlcmd

EXEC(@sqlcmd)