concept trick in category sql

This is an excerpt from Manning's book SQL Server MVP Deep Dives.
The technique of set-based iteration can lead to efficient solutions for problems that don’t lend themselves to declarative solutions, because those would result in an amount of work that grows exponentially with the amount of data. In those cases, the trick is to find a declarative query that solves a part of the problem (as much as feasible), and that doesn’t have the exponential performance problem—then repeat that query until all work has been done. So instead of attempting a single set-based leap, or taking millions of single-row-sized miniature steps in a cursor, set-based iteration arrives at the destination by taking a few seven-mile leaps.
This chapter covers performance and design tips and tricks that I’ve picked up over the years. When you’re through with the chapter, you’ll not only know how to design reports with the best possible performance, but you’ll also come away with new ways of solving problems. I guarantee that no matter how expert you are in Reporting Services (RS), you’ll find something new in this chapter.