2
Votes

Using TRY...CATCH in Transact-SQL

published 1028 days, 4 hours, 40 minutes ago posted by raazzraazz 1031 days, 23 hours, 37 minutes ago
Wednesday, July 29, 2009 8:00:00 AM GMT Saturday, July 25, 2009 1:03:44 PM GMT

Errors in Transact-SQL code can be processed by using a TRY…CATCH construct similar to the exception-handling features of the Microsoft Visual C++ and Microsoft Visual C# languages. A TRY…CATCH construct consists of two parts: a TRY block and a CATCH block. When an error condition is detected in a Transact-SQL statement that is inside a TRY block, control is passed to a CATCH block where the error can be processed.

After the CATCH block handles the exception, control is then transferred to the first Transact-SQL statement that follows the END CATCH statement. If the END CATCH statement is the last statement in a stored procedure or trigger, control is returned to the code that invoked the stored procedure or trigger. Transact-SQL statements in the TRY block following the statement that generates an error will not be executed.

Category: Technology | Clicked: 0 | | Source: msdn.microsoft.com | show counter code
Tags: SQL Server 2005, TRY CATCH

No comments yet, be the first one to post comment.

To post your comment please login or signup