SQL Flow Field Guide

CLOSE

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

closes a cursor

What changes

Input
open cursor
Output or change
cursor state (closed, result released)

Syntax at a glance

CLOSE { { [ GLOBAL ] cursor_name } | cursor_variable_name }

Work example

Cursor row processing is complete but the cursor declaration remains allocated.

Close the cursor on success and error paths. Keep DEALLOCATE separate so the lifecycle stays visible.

Check your work CLOSE. The cursor is closed before its declaration is released or reused.

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