Cursors (Transact-SQL)

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2008) ![yes](media/yes.png)Azure SQL Database ![no](media/no.png)Azure SQL Data Warehouse ![no](media/no.png)Parallel Data Warehouse

Microsoft Microsoft SQL Server statements produce a complete result set, but there are times when the results are best processed one row at a time. Opening a cursor on a result set allows processing the result set one row at a time. You can assign a cursor to a variable or parameter with a cursor data type.

Cursor operations are supported on these statements:

CLOSE

CREATE PROCEDURE

DEALLOCATE

DECLARE CURSOR

[DECLARE @local_variable](../../t-sql/language-elements/declare-local-variable-transact-sql.md)

DELETE

FETCH

OPEN

UPDATE

SET

These system functions and system stored procedures also support cursors:

[@@CURSOR_ROWS](../../t-sql/functions/cursor-rows-transact-sql.md)

CURSOR_STATUS

[@@FETCH_STATUS](../../t-sql/functions/fetch-status-transact-sql.md)

sp_cursor_list

sp_describe_cursor

sp_describe_cursor_columns

sp_describe_cursor_tables

See Also

Cursors