码迷,mamicode.com
首页 > 数据库 > 详细

sql 2008 游标

时间:2017-01-06 12:19:44      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:dea   nbsp   sel   cti   use   fetch   sql 2008   create   span   

    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 游标

标签:dea   nbsp   sel   cti   use   fetch   sql 2008   create   span   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!