标签:style blog color 使用 os for div ar
--基于查询声明游标 declare cur CURSOR FOR select id from OrderProducts where OrderCode =@OrderCode --select @OrderProductsId = id from OrderProducts where OrderCode =@OrderCode --打开游标 OPEN cur --读取下一个游标 FETCH NEXT FROM cur INTO @OrderProductsId --遍历游标记录,直至到达游标的末尾 WHILE (@@FETCH_STATUS = 0) BEGIN IF @OrderProductsId <> ‘‘ or @OrderProductsId is not null begin IF NOT EXISTS(SELECT 1 FROM OrderProducts WHERE IsInvented=0 AND id=@OrderProductsId) /*判断订单号是否是虚拟商品*/ BEGIN SET @error=-1080; GOTO FailedLabel; END end FETCH NEXT FROM cur INTO @OrderProductsId END --关闭游标 CLOSE cur --释放游标 DEALLOCATE cur
SQL SERVER 游标的使用,布布扣,bubuko.com
标签:style blog color 使用 os for div ar
原文地址:http://www.cnblogs.com/allenhua/p/3874355.html