SQL Flow Field Guide

CURSOR_STATUS

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

cursor state

What changes

Input
a cursor name or variable
Output or change
status code
Return type
smallint Return value Cursor name Cursor variable 1 The cursor result set has at least one row.For insensitive and keyset cursors, the result set has at least one row.For dynamic cursors, the result s

Syntax at a glance

CURSOR_STATUS ( { 'local' , 'cursor_name' } | { 'global' , 'cursor_name' } | { 'variable' , 'cursor_variable' } )

Work example

Inspect whether a named cursor or cursor variable is open and usable.

Test empty, one-row, and multi-row results. Read fetch status immediately and verify cleanup paths.

Check your work Interpret the code for the cursor kind and test closed, empty, and deallocated cases.

Open Microsoft Learn for full syntax, permissions, and details for your version.