Code Snippet posted by:
Arul44ece | Posted on: 10/11/2012 | Category:
SQL Server Codes | Views: 460 | Status:
[Member] |
Points: 40
|
Alert Moderator
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
Regards,
Arul R
arul44.ece@gmail.com