Hi
What are Cursors. Explain different types of Cursors. What are the disadvantages of Cursors. How can you avoid Cursors ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 9, 2012, 6:24 PM EDT
Cursors allow row-by-row prcessing of the resultsets.
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.
Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.
Most of the times, set based operations can be used instead of cursors.
Please refer the below link for the example of Types of cursors
http://www.dotnet-tricks.com/Tutorial/sqlserver?id=RLID060512&title=SQL%20Server%20-%20Types%20of%20Cursors
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted May 9, 2012, 8:05 PM EDT
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis.
plese refer http://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/ it is very good article.
type of corsor refer
http://technet.microsoft.com/en-us/library/ms172375.aspx
hope this help.
MuthuMari MRank #5,738 · 288 reputationPosted May 9, 2012, 9:16 PM EDT
Cursor is used for row-by row operations. The cursor is so named because it indicates the current position in the resultset.
A cursor is a set of rows together with a pointer that identifies a current row.
In other word, Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, its like recordset in the ASP and visual basic.
Types of Cursors:
1.Forward-only cursor do not support scrolling, they only support fetching rows serially from the start to end.
2.Static cursors are built in tempdb when the cursor is opened. They never reflect changes to the data. Static cursors are always read only, because it is built as a work table in tempdb.
3.Keyset driven cursors have the membership and order of rows in the result set fixed when the cursor is opened.
4.Dynamic cursors are the opposite of static cursors. Dynamic cursors reflect all changes made to the rows in their result set. The data values, order and membership of the rows in the result set can change on each fetch.
pls refer this url
http://www.sqlinfo.in/2011/04/sql-server-cursor-simple/
http://www.mssqlcity.com/Articles/General/UseCursor.htm
thanks
If this post is useful then mark it as "Accepted Answer"