SQL Flow Field Guide

Variables

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

none (documentation, rules or examples)

What changes

Input
none
Output or change
none

Syntax at a glance

n/a (reference page)

Work example

A batch needs a short-lived scalar or table-shaped value within one scope.

Declare an explicit type, assign before reading, and note where GO ends the local variable scope.

Check your work Variables. The variable has the expected type and is not read after its batch ends.

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