SQL Flow Field Guide

GOTO

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

unconditional jump to a label

What changes

Input
label
Output or change
none

Syntax at a glance

Define the label: label: Alter the execution: GOTO label

Work example

A controlled task needs the behavior documented for GOTO before it is added to a batch.

Read the linked Microsoft syntax and test GOTO with synthetic input in an isolated database. Record its scope, permissions, and error path.

Check your work GOTO. The observed GOTO behavior matches its written purpose and the test has no effect on permanent data or credentials.

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