sp_cursoroption (Transact-SQL)

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Sets cursor options or returns cursor information created by the sp_cursoropen stored procedure. sp_cursoroption is invoked by specifying ID =8 in a tabular data stream (TDS) packet.

|Applies to: SQL Server ( SQL Server 2008 through current version).|

Topic link icon Transact-SQL Syntax Conventions


sp_cursoroption cursor, code, value  


Is a handle value that is generated by SQL Server and returned by the sp_cursoropen stored procedure. cursor requires an int input value for execution.

Used to stipulate various factors of the cursor return values. code requires one of the following int input values:

Value Name Description
0x0001 TEXTPTR_ONLY Returns the text pointer, and not the actual data, for certain designated text or image columns.

TEXTPTR_ONLY allows text pointers to be used as handles to blob objects which can later be selectively retrieved or updated using Transact-SQL or DBLIB facilities (e.g. Transact-SQL READTEXT or DBLIB DBWRITETEXT).

If a "0" value is assigned, all of the text and image columns in the select list will return text pointers rather than data.
0x0002 CURSOR_NAME Assigns the name specified in value to the cursor. This, in turn, allows ODBC to use Transact-SQL positioned UPDATE/DELETE statements on cursors opened via sp_cursoropen.

The string can be specified as any character or Unicode data type.

Since Transact-SQL positioned UPDATE/DELETE statements operate, by default, on the first row in a fat cursor, sp_cursor SETPOSITION should be used to position the cursor before issuing the positioned UPDATE/DELETE statement.
0x0003 TEXTDATA Returns the actual data, not the text pointer, for certain text or image columns on subsequent fetches (i.e. this undoes the effect of TEXTPTR_ONLY).

If TEXTDATA is enabled for a particular column the row is re-fetched or refreshed, and can then be set back to TEXTPTR_ONLY. As with TEXTPTR_ONLY, the value parameter is an integer that specifies the column number and a zero value returns all text or image columns.
0x0004 SCROLLOPT Scroll option. See "Returned Code Values" later in this topic for additional information.
0x0005 CCOPT Concurrency control option. See "Returned Code Values" later in this topic for additional information.
0x0006 ROWCOUNT The number of rows currently in the result set.

Note: The ROWCOUNT may have changed since the value returned by sp_cursoropen if asynchronous population is being used. The value –1 is returned if the number of rows is unknown.

Designates the value returned by code. value is a required parameter that calls for a 0x0001, 0x0002, or 0x0003 code input value.


A code value of 2 is a string data type. Any other code value input or returned by value is an integer.

Return Code Values

The value parameter may return one of the following code values.

Return value Description
0X0005 CCOPT

The value parameter returns one of the following SCROLLOPT values.

Return value Description
0x0001 KEYSET
0x0002 DYNAMIC
0x0008 STATIC

The value parameter returns one of the following CCOPT values.

Return value Description
0x0001 READ_ONLY
0x0004 or 0x0008 OPTIMISTIC

See Also

System Stored Procedures (Transact-SQL)
sp_cursor (Transact-SQL)
sp_cursoropen (Transact-SQL)