欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

sqlserver刷新视图

程序员文章站 2022-05-07 21:28:32
sqlserver用于刷新视图的存储过程 create procedure dbo.proc_refreshview as begin declare @viewname varchar(100) declare cur_view cursor for select [name] from syso ......

sqlserver用于刷新视图的存储过程

create procedure dbo.proc_refreshview
as
begin
    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_view
end