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