Avoid cursors in SQL Server with these methods to loop over records

November 24, 2008

[From Search SQL Server]

Many articles have beaten up on SQL Server cursors -- database objects that manipulate data in a set on a row-by-row basis -- and I want to add my name to the list of people who wish cursors had never been introduced. But, unfortunately, cursors are a fact of life. Problems with cursors include extending locks, their inability to cache execution plans and CPU/RAM overhead. Many T-SQL programmers and DBAs do not know how to successfully loop over records without the need for cursors. In this tip, I'll share some alternatives to cursors that provide looping functionality.

The article continues at http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1339242,00.html