SQL Flow Field Guide

RETURN

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

exits the batch or module

What changes

Input
optional integer expression
Output or change
return status to the caller
Return type
Optionally returns int. Note Unless documented otherwise, all system stored procedures return a value of 0. This indicates success and a nonzero value indicates failure.

Syntax at a glance

RETURN [ integer_expression ]

Work example

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

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

Check your work Two results appear. First batch appears before RETURN, and Second batch appears after GO.

Practice SQL

Open in SQL Flow
SELECT N'First batch' AS Observation;
RETURN;
SELECT N'Skipped' AS Observation;
GO
SELECT N'Second batch' AS Observation;

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