Home > MSSQL, Tips and Tricks > SQL Server: Refresh View Metadata

SQL Server: Refresh View Metadata

After making changes to tables, you may need to refresh the metedata of the views pointing to those tables.
To refresh the metadata of all views in the database, use this

USE {database name here}

SELECT @sqlcmd = @sqlcmd + 'EXEC sp_refreshview ''' + name + ''';'
FROM sys.objects AS so
WHERE so.type = 'V'

SELECT @sqlcmd

-- uncomment to execute

Categories: MSSQL, Tips and Tricks Tags:
  1. No comments yet.
  1. No trackbacks yet.