declare @cursor1_status --hold the first fetch status
declare @cursor1_holder
declare @cursor2_status --hold the second fetch status
declare @cursor2_holder
--declare cursors
declare first_cursor cursor for....
declare second_cursor cursor for....
--open cursors
open first_cursor
open second_cursor
--fetch cursors and use another variable to hold the fetch -- status
fetch next from first_cursor into @cursor1_holder
select @cursor1_status = @@fetch_status
fetch next from second_cursor into @cursor2_holder
select @cursor2_status = @@fetch_status
while @cursor1_status = 0 --while cursor still has data
begin
.......
while @cursor2_status = 0
begin
..........
fetch next from second_cursor into @cursor2_holder
select @cursor2_status = @@fetch_status
end
fetch next from first_cursor into @cursor1_holder
select @cursor1_status = @@fetch_status
--go back to first record of second_cursor to start
--loop again
fetch first from second_cursor into @cursor2_holder
select @cursor2_status = @@fetch_status
end
close and deallocate cursors