T-SQL Tutorial

T-SQL Error_number()


Return the code number of the error that use the CATCH block of a TRY ... CATCH.

Error_number() Syntax

ERROR_NUMBER();

Error_number() Example

USE model;
GO
BEGIN TRY
   SELECT 18/0;
END TRY
BEGIN CATCH
   SELECT ERROR_NUMBER() AS Error_Number;
END CATCH;
GO

Error_Number
8134

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