What is cursors?where we need?and advantages

Posted by Sheeba under Sql Server on 12/3/2010 | Points: 10 | Views : 9189 | Status : [Member] | Replies : 3
Hi

What is cursors? where we need? what are all the advantages?

examples plz

Thanks




Responses

Posted by: Raja on: 12/3/2010 [Member] Starter | Points: 25

Up
0
Down
Please go through this thread http://www.dotnetfunda.com/forums/thread673-cursor-in-sql-server.aspx

The better overview about cursor is given at http://www.sqlteam.com/article/cursors-an-overview
In summary Cursor is a mechanism to iterate through collection of data in sql server, however please note that cursor is very slow. In the latest version of SQL server you can use CTE and other mechanism to achieve the same thing. So ideally we should not talk about its advantages ;).

Read the SQLTeam link and you will know about Cursor better.

Thanks



Regards,
Raja, USA

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 12/3/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Sheeba,

Refer those links...

http://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/

http://www.mssqltips.com/tip.asp?tip=1599

If you using Cursor in Stored Procedure means performance level its very slow compare to normal while loop.

Thanks,
T.Saravanan

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sivaprasadadiraju on: 12/4/2010 [Member] Starter | Points: 25

Up
0
Down
Hi

http://techrepublic.com.com/5208-6230-0.html?forumID=101&threadID=204486&start=0
http://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/

Cursor is going to use when row by row operations has to be done. it will work like loop. it is not good to use
you can use for or while loop instead of cursor

Regards,
Siva Prasad Adiraju

SIVA PRASAD ADIRAJU

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response