首页 > 开发 > 综合 > 正文

刷新数据库视图

2024-07-21 02:13:52
字体:
来源:转载
供稿:网友

/*
    刷新数据库视图.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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表