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…

Read more
Uncategorized

Drop all views in database

DECLARE @Stmt NVARCHAR(MAX) SET @Stmt = ” SELECT @Stmt = @Stmt + ‘DROP VIEW [‘ + s.name + ‘].[‘ + v.name + ‘];’ FROM sys.views v INNER JOIN sys.schemas s ON s.schema_id = v.schema_id EXECUTE (@Stmt) GO SELECT * FROM sys.views GO