视图|数据|数据库|刷新
/*
刷新数据库视图.sql
*/
DECLARE vName sysname
DECLARE refresh_cursor CURSOR FOR
SELECT Name from sysobjects WHERE xtype = 'V' order by crdate
FOR READ ONLY
OPEN refresh_cursor
FETCH NEXT FROM refresh_cursor
INTO vName
WHILE FETCH_STATUS = 0
BEGIN
--刷新指定视图的元数据。由于视图所依赖的基础对象的更改,视图的持久元数据会过期。
exec sp_refreshview vName
PRINT '视图' + vName + '已更新'
FETCH NEXT FROM refresh_cursor
INTO vName
END
CLOSE refresh_cursor
DEALLOCATE refresh_cursor
刷新数据库视图
80酷酷网 80kuku.com