Hi ,
In the below query is example for cursor.
Here fetch record one by one from table .
declare @taskid varchar(50)
declare @task_details cursor //Declare cursor
set @task_details=cursor
FOR
select taskid from tasklist order by taskid desc
open @task_details //open the cursor
fetch next
from @task_details into @taskid
while @@FETCH_STATUS=0
begin
print @taskid
fetch next from @task_details into @taskid
end
close @task_details // close
deallocate @task_details // deallocation