SQL Flow Field Guide

@@FETCH_STATUS

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

cursor state

What changes

Input
last FETCH result in the connection
Output or change
int (0 success)
Return type
integer

Syntax at a glance

@@FETCH_STATUS

Work example

Check the result of the most recent cursor fetch.

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

Check your work Read it immediately after FETCH because another cursor can replace the status.

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