sqlserver 用于刷新当前数据库所有视图的存储过程

create procedure dbo.proc_refreshviewasbegin
    declare @viewname varchar(100)    declare cur_view cursor for select [name] from sysobjects where [type]='V'
    open cur_view    fetch next from cur_view into @viewname
    while(@@FETCH_STATUS=0)    begin
        exec sp_refreshview @viewname

        fetch next from cur_view into @viewname
    end
    close cur_view    deallocate cur_viewend