SQL 重建所有的视图

declare @s nvarchar(4000) 
declare tb cursor local for 
  select 'sp_refreshview '''+name+'''' 
  from sysobjects 
  where xtype='V' and status>=0 order by name
open tb 
fetch tb into @s 
while @@fetch_status=0 
begin 
--select @s
  exec(@s) 
fetch tb into @s 
end 
close tb 
deallocate tb

 

posted @ 2021-04-13 15:46  封存。  阅读(66)  评论(0)    收藏  举报