The TRY...CATCH construnct was introduced with SQL Server 2005 for error handling using T-SQL. Statements to be tested for an error are enclosed in a BEGIN TRY ... END TRY block.
A CATCH block immediately follows the TRY block, and error-handling logic is stored here. The following examples shows the basic syntax:
-- code that may produce errors
-- error handling logic
SQL Server evaluates each statement in TRY block sequentially. If a runtime error is encountered, control immediately jumps to the CATCH block, and error information can be retrieved, logged, and displayed to the user.