Try Catch

BEGIN TRY
--Process that may create an error
END TRY
BEGIN CATCH
--Process to handle error
END CATCH
Function NameFunction Definition
ERROR_LINEThe line number the error occurred on.
ERROR_MESSAGEPlain language description of the error.
ERROR_NUMBERThe number of the error.
ERROR_PROCEDUREThe name of the function or stored procedure that produced the error.
ERROR_SEVERITYThe severity value of the error.
ERROR_STATEThe state number of the error.
USE demo

BEGIN TRY
Print 1/0
END TRY
BEGIN CATCH
PRINT 'Error '+CAST(ERROR_NUMBER()AS NVARCHAR(6))+' '+ERROR_MESSAGE()
END CATCH