存储过程游标模板

DECLARE BLBL_CURSOR CURSOR FOR
SELECT ref.RefBillID FROM Table2 ref
WHERE ref.BillID=@Parm_BillID

OPEN BLBL_CURSOR
FETCH NEXT FROM BLBL_CURSOR INTO @sRefBillID
WHILE @@FETCH_STATUS = 0
BEGIN

--exec dbo.SP_Recall @sRefBillID, @rtnCode output, @rtnText output

FETCH NEXT FROM BLBL_CURSOR INTO @sRefBillID
END
CLOSE BLBL_CURSOR
DEALLOCATE BLBL_CURSOR

原文地址:https://www.cnblogs.com/furenjian/p/7497312.html