Another way to return information to the user is to use cursors. A cursor is an object you can create in the database that is used to store multiple rows of data. This object can be looped through on a row-by-row basis, and operations can be performed against each row. In basic terms, cursors are similar to arrays in any other programming language.
There are five steps to working with cursors in SQL Server:
|DECLARE the cursor||This process tells SQL Server that you are going to create a specific type of cursor. During the declaration, you specify a name for the cursor and SELECT statement, which will make up the rows through which the cursor loops.|
|OPEN the cursor ...|