SQL CURSOR 同时选择多列值

首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

SQL CURSOR 同时选择多列值

作者:  时间: 2011-05-23

  DECLARE @ofId int,@Amount decimal(18,2),@OrderID varchar(20)
  DECLARE curOfId CURSOR FOR
  SELECT lotOfId,lotWinMoney,t1.lotOrderID
  FROM IP_OrderLottery AS t1 INNER JOIN View_OfficeInfo_CityCountry AS t2
  ON t1.lotOfId=t2.ofId
  WHERE t1.lotIsUpdateReward=0
  OPEN curOfId 
  FETCH NEXT FROM curOfId INTO @ofId,@Amount,@OrderID
  
  WHILE @@FETCH_STATUS = 0
  BEGIN
   PRINT @ofId
   PRINT @Amount
   PRINT @OrderID
   FETCH NEXT FROM curOfId INTO @ofId,@Amount,@OrderID
  END
  CLOSE curOfId
  DEALLOCATE curOfId