--重新编译所有视图
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