这个很好办,你在你的游标循环中加一个变量纪录滚过的纪录即可
如:
declare @cur_pos int
declare mycursor cursor for select col1,col2 from mytable
declare @col1 char(10)
declare @col2 char(10)
open mycusor
fetch next mycursor into @col1,@col2
while @@fetch_status<>-1
begin
.....
--您的处理
select @cur_pos=@cur_pos+1
fetch next mycursor into @col1,@col2
end
declare @cur_pos int
declare mycursor cursor for select col1,col2 from mytable
declare @col1 char(10)
declare @col2 char(10)
open mycusor
select @cur_pos=@cur_pos+1
fetch next mycursor into @col1,@col2
while @@fetch_status<>-1
begin
原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/277609.html