An object called a database cursor makes it possible to browse through the rows of a result set. Unlike TSQL commands that operate on all the rows in the result set at one time, it enables you to handle a single row from the result set of a query.
Sometimes, you might want to process, examine, or change a data set row by row. Cursors are useful in situations like this.
When iterating through data one row at a time or finishing a procedure in a serial fashion, where serialized processing is required on SQL Server Administrative tasks, cursors are helpful.
The declaration, opening, and fetching of the rows into the action are the first steps in the cursor’s life cycle. Once the row-by-row processing is finished, the cursor should be closed and deallocated.

For examples, please click here.
One comment