SQL - Cursor Functions


In SQL Server, a cursor is a database object that enables us to retrieve and modify data from individual rows one at a time. Nothing more than a row pointer is what a cursor actually is. It always goes together with a SELECT statement. Typically, it consists of a set of SQL statements that iterate through each row one at a time in a set number of rows.

All Cursor functions are nondeterministic. To put it another way, even with the identical set of input values, these functions do not provide the same outcomes when called.

List of Functions

Following is a list of scalar functions that returns information about cursors in the SQL server −

Sr.No. Function & Description
1 @@CURSOR_ROWS

Is used to determine the number of rows in the current cursor.

2 @@FETCH_STATUS

Is used to retrieve the most recent opened cursor's current fetch status.

3 CURSOR_STATUS

Is used to determine the current cursor's status.

Advertisements