What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 21301 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > Cursor ...
Arul44ece

Cursor

 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
Found interesting? Add this to:


 Responses

Jasminej
Posted by: Jasminej | Posted on: 10/3/2012 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

Is this working in SQL Server ?

Arul44ece
Posted by: Arul44ece | Posted on: 11/28/2012 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

Hi Jasmine,

Yes ,working fine.

did u face any issue

Regards,

Arul R
arul44.ece@gmail.com

>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 6:23:18 AM