sql語句游標的寫法


當循環查找一張表的信息時,我們得寫一張游標來對每條信息進行操作,具體格式如下

 

DECLARE @fitemid int

DECLARE #point_cursor CURSOR
FOR
SELECT fitemid
FROM ICStockBillEntry where finterid=1314     --每條信息從頭到尾的寫入
OPEN #point_cursor
FETCH NEXT FROM #point_cursor INTO @fitemid
while @@fetch_status = 0
BEGIN
select @fitemid= from table          --具體的邏輯
FETCH NEXT FROM #point_cursor INTO @fitemid
END
CLOSE #point_cursor
DEALLOCATE #point_cursor


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM