---
title: "sp_cursoroption (Transact-SQL) | Microsoft Docs"
ms.custom: ""
ms.date: "03/14/2017"
ms.prod: "sql-non-specified"
ms.reviewer: ""
ms.suite: ""
ms.technology:
- "database-engine"
ms.tgt_pltfrm: ""
ms.topic: "language-reference"
f1_keywords:
- "sp_cursoroption_TSQL"
- "sp_cursoroption"
dev_langs:
- "TSQL"
helpviewer_keywords:
- "sp_cursoroption"
ms.assetid: 88fc1dba-f4cb-47c0-92c2-bf398f4a382e
caps.latest.revision: 8
author: "BYHAM"
ms.author: "rickbyh"
manager: "jhubbard"
---
# sp_cursoroption (Transact-SQL)
[!INCLUDE[tsql-appliesto-ss2008-xxxx-xxxx-xxx_md](../../includes/tsql-appliesto-ss2008-xxxx-xxxx-xxx-md.md)]
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**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] ([!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)] through [current version](http://go.microsoft.com/fwlink/p/?LinkId=299658)).|
 [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
## Syntax
```
sp_cursoroption cursor, code, value
```
## Arguments
*cursor*
Is a *handle* value that is generated by [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and returned by the sp_cursoropen stored procedure. *cursor* requires an **int** input value for execution.
*code*
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 [!INCLUDE[tsql](../../includes/tsql-md.md)] or DBLIB facilities (e.g. [!INCLUDE[tsql](../../includes/tsql-md.md)] 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 [!INCLUDE[tsql](../../includes/tsql-md.md)] positioned UPDATE/DELETE statements on cursors opened via sp_cursoropen.
The string can be specified as any character or Unicode data type.
Since [!INCLUDE[tsql](../../includes/tsql-md.md)] 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.|
*value*
Designates the value returned by *code*. *value* is a required parameter that calls for a 0x0001, 0x0002, or 0x0003 *code* input value.
> [!NOTE]
> 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|
|------------------|-----------------|
|0x0004|SCROLLOPT|
|0X0005|CCOPT|
|0X0006|ROWCOUNT|
The *value* parameter returns one of the following SCROLLOPT values.
|Return value|Description|
|------------------|-----------------|
|0x0001|KEYSET|
|0x0002|DYNAMIC|
|0x0004|FORWARD_ONLY|
|0x0008|STATIC|
The *value* parameter returns one of the following CCOPT values.
|Return value|Description|
|------------------|-----------------|
|0x0001|READ_ONLY|
|0x0002|SCROLL_LOCKS|
|0x0004 or 0x0008|OPTIMISTIC|
## See Also
[System Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/system-stored-procedures-transact-sql.md)
[sp_cursor (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-cursor-transact-sql.md)
[sp_cursoropen (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-cursoropen-transact-sql.md)