SQL Flow Field Guide

ERROR_SEVERITY

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

reads error state

What changes

Input
the error that activated the current CATCH block
Output or change
error attribute (NULL outside CATCH)
Return type
int

Syntax at a glance

ERROR_SEVERITY ( )

Work example

Read the severity of a caught error.

Read state in the intended scope and immediately after the statement it describes. Treat host values as untrusted.

Check your work Use inside CATCH and do not use severity alone as a retry rule.

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