Posted inSQL
SQL Server Exception Handling by TRY…CATCH
TRY..CATCH Syntax
BEGIN TRY
--T-SQL statements
--or T-SQL statement blocks
END TRY
BEGIN CATCH
--T-SQL statements
--or T-SQL statement blocks
END CATCH
Error Functions used within CATCH block
ERROR_NUMBER()
This returns the error number and its value is same as for @@ERROR function.
ERROR_LINE()
This returns the line number of T-SQL statement that caused error.
ERROR_SEVERITY()
This returns the severity level of the error.
ERROR_STATE()