SQL Flow Field Guide

ERROR_PROCEDURE

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
nvarchar(128)

Syntax at a glance

ERROR_PROCEDURE ( )

Work example

Read the stored procedure or trigger that raised a caught error.

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

Check your work It can be null outside a stored module, so record the error number too.

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