July 2014
Intermediate to advanced
214 pages
4h 47m
English
Like other programming languages, T-SQL provides a sophisticated mechanism that captures and handles errors during execution. The mechanism for handling errors during execution includes the object-oriented-programming-style TRY…CATCH construct. When writing Transact-SQL batches and programmable objects, we wrap the Transact-SQL statements to be executed within a TRY block, and at runtime, if an error occurs, control is sent to the CATCH block. We enclose error-handling code within the CATCH block. The syntax for the TRY…CATCH construct is as follows:
BEGIN TRY
{ sql_statement |statement_block}
END TRY
BEGIN CATCH
[{ sql_statement |statement_block}]
END CATCHOnly errors with severity between 11 and 19 cause the CATCH ...