Cursor Architecture
All SQL statements operate on a set of rows. A SELECT statement returns a complete result set containing all the rows that meet the qualifications in the SELECT statement. Applications need to process the result set one row or block of rows at a time. Cursors are a logical extension to result sets that let applications work with the result set row by row.
Microsoft® SQL Server™ 2000 supports several mechanisms for specifying cursors:
- Transact-SQL supports the SQL-92 DECLARE CURSOR, OPEN, FETCH, and CLOSE statements for managing cursors. Transact-SQL also supports cursor extensions such as:
- A DEALLOCATE statement to allow optimizations in reusing cursors.
- Defining a Transact-SQL variable to have a cursor data type and then using it to refer to a cursor.
- Defining a cursor to have local or global scope.
- Specifying the cursor types from the OLE DB and ODBC specifications (FORWARD_ONLY, STATIC, KEYSET, and DYNAMIC) in a DECLARE CURSOR statement.
- A DEALLOCATE statement to allow optimizations in reusing cursors.
- The Microsoft OLE DB Provider for SQL Server supports the cursor functionality of the ADO and OLE DB APIs.
- The Microsoft SQL Server ODBC driver supports the cursor functionality of the ODBC, RDO, DAO, and Microsoft Foundation Classes Database Classes APIs.
- Microsoft Embedded SQL for C supports the cursor functionality of the Embedded SQL standard.
- The DB-Library API supports the same level of cursor functionality as the OLE DB and ODBC APIs.