存儲(chǔ)過程游標(biāo)的詳解 存儲(chǔ)過程中游標(biāo)是怎么用的?
存儲(chǔ)過程中游標(biāo)是怎么用的?交替程序[dbo]。[存儲(chǔ)過程名稱]asbegindeclare cursor name cursorforselect column name from table nam
存儲(chǔ)過程中游標(biāo)是怎么用的?
交替程序[dbo]。[存儲(chǔ)過程名稱]asbegindeclare cursor name cursorforselect column name from table name其中條件首先聲明光標(biāo)指向查詢結(jié)果,一列或多列正常,條件自定義聲明變量名varchar(400)--存儲(chǔ)獲得的值,open tag name--open cursor while@fetch Status=0--value beginfetchnextfrom cursor name into variable name--這樣,光標(biāo)指向下一行,第一行的值傳遞給變量-----要執(zhí)行的操作,如修改表中的字段,更新表名,設(shè)置column name=value where=variable name--------endclose Tag name--close cursor deallocate Tag name--release cursor end