How would you handle error in Sql Server 2008?

 Posted by Sumank on 5/17/2013 | Category: Sql Server Interview questions | Views: 3180 | Points: 40
Answer:

SQL Server now supports the use of TRY...CATCH for handling errors. TRY...CATCH lets us build error handling at the level we need, 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.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response