SQL Flow Field Guide

TRY...CATCH

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

error handling: errors with severity above 10 transfer control to CATCH

What changes

Input
errors raised in the TRY block
Output or change
none

Syntax at a glance

BEGIN TRY { sql_statement | statement_block } END TRY BEGIN CATCH [ { sql_statement | statement_block } ] END CATCH [ ; ]

Work example

A procedure needs one controlled error path that records or returns a failure without hiding it.

Keep the protected work in TRY and the recovery path in CATCH. Preserve the original error with THROW after any cleanup.

Check your work TRY...CATCH. A handled failure reaches CATCH and the caller still receives the original error number and state.

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