SQL Flow Field Guide

ERROR_LINE

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_LINE ( )

Work example

Read the source line 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 Use inside CATCH and retain procedure name and error number for diagnosis.

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