SQL Server MVP Deep Dives
by Adam Machanic, Greg Low, Kimberly Tripp, Paul S. Randal, Kalen Delaney, Paul Nielsen
Chapter 4. Set-based iteration, the third alternative
Hugo Kornelis
When reading SQL Server newsgroups or blogs, you could easily get the impression that there are two ways to manipulate data: declarative (set-based) or iterative (cursor-based). And that iterative code is always bad and should be avoided like the plague.
Those impressions are both wrong.
Iterative code isn’t always bad (though, in all honesty, it usually is). And there’s more to SQL Server than declarative or iterative—there are ways to combine them, adding their strengths and avoiding their weaknesses. This article is about one such method: set-based iteration.
The technique of set-based iteration can lead to efficient solutions for problems that don’t lend themselves to ...
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