O'Reilly logo

Guru's Guide to SQL Server Architecture and Internals, The by Ken Henderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transact-SQL Cursor Syntax

A number of commands and functions relate to cursors. Table 14.2 summarizes them. The following subsections cover these commands in more detail.

Table 14.2. Transact-SQL Cursor Commands and Functions
Command or FunctionPurpose
DECLARE CURSORDefines a cursor
OPENOpens a cursor so that data may be retrieved from it
FETCHFetches a single row from the cursor
CLOSECloses the cursor, leaving intact the internal structures that service it
DEALLOCATEFrees the cursor's internal structures
@@CURSOR_ROWSReturns the number of rows exposed by the cursor
@@FETCH_STATUSIndicates the success or failure of the last FETCH
CURSOR_STATUSReports status information for cursors and cursor variables

DECLARE CURSOR

DECLARE CURSOR defines cursors. There ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required