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:
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 |