We've all heard that definitive statement: "Avoid using cursors." But, in my opinion, what really should be conveyed is: "Avoid using row-by-row operations when possible."
2016-09-09 (first published: 2015-06-01)
13,532 reads
Using a CURSOR is not normally the best way to process through a set of records. Yet when a seasoned programmer moves to writing TSQL for the first time they frequently look for ways to process a sets of records one row at a time. They do this because they are not used to thinking about processing records as a set. In order to process through a TSQL record set a row at a time you can use a cursor. A cursor is a record set that is defined with the DECLARE CURSOR statement. Cursors can be defined as either read-only or updatable. In this article I will introduce you to using cursors to do record level processing one row at a time.
2021-04-14 (first published: 2015-05-06)
11,499 reads
Exploring some differences between using cursors, local fast forward cursors and using set logic.
2016-11-11 (first published: 2015-02-03)
15,438 reads
Cursors are considered by many to be the bane of good T-SQL. What are the best ways to avoid iterative T-SQL and to write queries that look and perform beautifully? This first part in an ongoing series of cursor-killing handles inter-row analysis.
2015-12-18 (first published: 2014-05-27)
22,496 reads
I'm no big fan of dynamic SQL or cursors, however there are times where they do the job.
2013-11-08 (first published: 2013-10-29)
1,835 reads
An inline table-valued function (iTVF) that will produce a virtual tally table on-the-fly. The function creates a tally table of any size with user-defined lower and upper bounds.
2014-09-08 (first published: 2013-06-28)
2,193 reads