SQL Flow Field Guide

DEALLOCATE

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

deallocates a cursor

What changes

Input
cursor reference
Output or change
cursor removed

Syntax at a glance

DEALLOCATE { { [ GLOBAL ] cursor_name } | @cursor_variable_name }

Work example

A cursor is no longer needed and its reference should be released.

Deallocate it after CLOSE. Review every early return and catch path for a matching cleanup step.

Check your work DEALLOCATE. No live cursor reference remains after the routine finishes.

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