SQL Flow Field Guide

:EXIT

Check your sqlcmd client variant and platform

End the client and optionally return a value calculated by SQL Server.

Syntax at a glance

:EXIT [ ( statement ) ]

Work example

Return a validation status to a build step

In a lab run, use :EXIT(SELECT 7). Capture the exit code in the calling shell.

Check your work The shell receives 7 from this example. Keep application exit codes small for portability.

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