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

SQL 游标

时间:2015-06-08 16:54:18      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

declare @MId bigint
declare update_network cursor for   --定义游标
select MerchantId from Sys_CCOO_Network
open update_network   --打开游标
fetch next from update_network into @MId
WHILE @@FETCH_STATUS = 0  --执行循环
BEGIN
declare @packageId bigint=0
select top 1 @packageId=B.PackageId from sys_ccoo_order A join
Sys_CCOO_PurchaseRecords B on A.Id =B.corderId
join Sys_Product C
on C.Id=B.PackageId
and C.packageService=‘YWFW‘
where A.MerchantId=@MId
if(ISNULL(@packageId,0)>0)
begin
update Sys_CCOO_Network set defaultpackageId=@packageId where MerchantId=@MId
end
fetch next from update_network into @MId
END
CLOSE update_network  --关闭游标
DEALLOCATE update_network  --释放游标

SQL 游标

标签:

原文地址:http://www.cnblogs.com/linsu/p/4561099.html

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