SQL Flow Field Guide

Cursor (data type)

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

cursor variables and OUTPUT parameters

What changes

Input
none
Output or change
none

Syntax at a glance

DECLARE @cursor_variable CURSOR

Work example

Use a cursor only when a task must call an operation once per fetched row and a set-based statement cannot express it.

Review fetch status, close and deallocate paths, and whether the work can be rewritten as one statement.

Check your work A cursor is procedural state with cleanup needs, not a column type for ordinary table design.

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