Error_message() TSQL Tutorial

Return the message text of the error that use the CATCH block of a TRY ... CATCH.

Error_message() Syntax

ERROR_MESSAGE();

Error_message() Example

USE model;
GO
BEGIN TRY
   SELECT -5*9/0;
END TRY
BEGIN CATCH
   SELECT ERROR_MESSAGE() AS Error_Message;
END CATCH;
GO

Error_Message
Divide by zero error encountered.

See also:
T-SQL Functions -> ERROR_LINE()