SQL Flow Field Guide

OPEN

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

executes the cursor query

What changes

Input
cursor query sources
Output or change
populated cursor

Syntax at a glance

OPEN { { [ GLOBAL ] cursor_name } | cursor_variable_name }

Work example

A declared cursor is ready to acquire its result set for a controlled loop.

Open it once, then check the first fetch status. Keep the cursor lifetime inside the smallest block that needs it.

Check your work OPEN. The cursor is open before FETCH and is closed on both success and error paths.

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