程序笔记
随心而记

--方法一:
declare       @s       nvarchar(2000)      
declare       tb       cursor       local       for      
select     'exec   sp_refreshview   '       +name  
from       sysobjects          
where       xtype= 'v '       and       status> =0      
open       tb          
fetch     next   from   tb       into       @s      
while       @@fetch_status=0      
begin      
                    exec(@s)      
                    fetch     next   from   tb       into       @s      
end      
close       tb      
deallocate       tb 
--方法二:
declare   @a   varchar(8000)
select  @a=isnull(@a+ ';'+char(13), '')+ 'exec   sp_refreshview   '+ name 
from       sysobjects          
where       xtype= 'v' and status >= 0
--from   information_schema.view_table_usage   where   table_name= '改动的表名 '
exec(@a)

posted on 2008-10-31 10:36    阅读(226)  评论(0编辑  收藏  举报