首页 > 数据库技术 > 详细

sql 2008 游标

时间:2017-01-06 12:18:06      阅读:175      评论:0      收藏:0      [点我收藏+]
    begin
        declare PlatformBulletin --定义游标
        cursor for select UserID,ZMSCompanyID from base_UserCompany where isActive = 1
        
        open PlatformBulletin --打开游标
        declare @userid int,@zmscompanyid int
        
        fetch next from PlatformBulletin into @userid,@zmscompanyid
        while (@@fetch_status=0)
        begin
            insert into oa_BulletinUser(BulletinID,AttachmentGUID,ToUserID,IsRead,ReadTime,CreateTime,ZMSCompanyID) 
                values(@bulletinid,‘‘,@userid,0,null,GETDATE(),@zmscompanyid)
                
            fetch next from PlatformBulletin into @userid,@zmscompanyid
        end
        
        close PlatformBulletin --关闭游标
        deallocate PlatformBulletin --释放游标
    end

 

sql 2008 游标

原文:http://www.cnblogs.com/hz1234/p/6255590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!