sql server 重新编译所有视图

--重新编译所有视图
declare   @s   nvarchar(4000)
declare   tb   cursor   local   for
select   'sp_refreshview   '''+name+ ' '' '  
from   sysobjects  
where   xtype= 'V '   and   status> =0
open   tb  
fetch   tb   into   @s
while   @@fetch_status=0
begin
exec(@s)
fetch   tb   into   @s
end
close   tb
deallocate   tb

posted @ 2013-04-08 11:31  旦旦哥  阅读(430)  评论(0编辑  收藏  举报