Inside Microsoft® SQL Server® 2008: T-SQL Programming
by Dejan Sarka Itzik Ben-Gan Greg Low, Roger Wolter, Ed Katibah, and Isaac Kunen
Chapter 8. Cursors
Itzik Ben-Gan
A cursor is a programmatic construct in T-SQL. It represents a result set of a query that you can iterate through one row at a time, possibly in a predetermined order. Programmers who are used to procedural programming but are not yet experienced with SQL tend to use cursors a lot because using cursors feels like an extension of what they already know. However, you should be aware of the implications of using cursors. Using cursors is not in accord with the relational model, which deals with whole sets, as opposed to dealing with individual rows. By using cursors, you pretty much go against the model. Also, in terms of the work done by the Microsoft SQL Server engine, the processing of each cursor row incurs an ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access