SQL Flow Field Guide

THROW

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

raises an exception (severity 16); requires preceding ;

What changes

Input
error number, message, state (or re-throw in CATCH)
Output or change
error to the caller or enclosing CATCH

Syntax at a glance

THROW [ { error_number | @local_variable } , { message | @local_variable } , { state | @local_variable } ] [ ; ]

Work example

A procedure must raise a specific error or pass the caught error to its caller.

Use THROW for new code. When rethrowing inside CATCH, use the parameterless form to keep the original error details.

Check your work THROW. The caller receives the intended error number, state, and message. The failure is not converted to a success result.

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