1.

How Would You Handle Error In Sql Server 2008?

Answer»

SQL Server now supports the use of TRY…CATCH constructs for PROVIDING rich error handling. TRY…CATCH lets us build error handling at the level we need, in the way we need to, by setting a region where if any error OCCURS, it will break out of the region and head to an error handler. The basic structure is as FOLLOWS:

BEGIN TRY
<code>
END TRY
BEGIN CATCH
<code>
END CATCH

So if any error occurs in the TRY block, execution is DIVERTED to the CATCH block, and the error can be dealt.

 

SQL Server now supports the use of TRY…CATCH constructs for providing rich error handling. TRY…CATCH lets us build error handling at the level we need, in the way we need to, by setting a region where if any error occurs, it will break out of the region and head to an error handler. The basic structure is as follows:

So if any error occurs in the TRY block, execution is diverted to the CATCH block, and the error can be dealt.

 



Discussion

No Comment Found