System stored procedures This document contains information on undocumented stored procedures in Microsoft SQL Server.
Name Function sp_cursor Update a cursor sp_cursorclose close a cursor sp_cursorexecute Open a prepared cursor sp_cursorfetch Fetch rows sp_cursoropen Open a cursor sp_cursoroption Set cursor options sp_cursorprepare Prepare a cursor statement sp_cursorprepexec Prepare a cursor statement and open sp_cursorunprepare Free a prepared cursor statement sp_execute Execute a prepared statement sp_prepare Prepare an SQL statement sp_prepexec Prepare and execute an SQL statement sp_unprepare Free a prepared statement
sp_cursoropen Defines the attributes of an API server cursor, such as its scrolling behavior and the statement used to build the result set on which the cursor operates, then populates the cursor. The statement can contain embedded parameters.
Arguments [@cursor =] cursor_handle OUTPUT Is the name of a declared integer variable to receive the cursor handle. cursor_handle is int, with no default. [@stmt =] 'stmt' Is a string containing a single SELECT statement or a single stored procedure call. The size of the string is limited only by available database server memory. stmt can contain parameters having the same form as a variable name, for example:
'SELECT * FROM Employees WHERE EmployeeID = @IDParameter'
Each parameter included in stmt must have a corresponding entry in both the @paramdef parameter definition list and the parameter values list.
[@scrollopt =] scroll_options OUTPUT Is the cursor scroll type. scroll_options is int with a default of 1 (keyset-driven), and can be a combination of these values (exactly one of the first 5 must be specified).