温习存储过程的CURSOR

use esales
declare @myid int
select @myid=2

declare @nCorpID int
declare @nCorpIDDest int
declare @nAction int
declare @nNum int

 

    declare cursorProcNames cursor for
   SELECT nCorpID,nCorpIDDest,nAction,nNum
   FROM tblOrder
   WHERE (nCorpID = @myid) OR
         (nCorpIDDest = @myid)
    open cursorProcNames

    while 1 = 1
    begin
        fetch next from cursorProcNames into @nCorpID,@nCorpIDDest,@nAction,@nNum
        if @@fetch_status <> 0
            break
 print @nAction
    end

 

posted on 2005-06-27 15:26  DiviSoft  阅读(529)  评论(0编辑  收藏  举报

导航