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