Kevin Wilkie breaks out the catcher’s mitt:
In our last post, we started talking about transactions and how they can help your databases have data integrity. Let’s continue that today with our friends TRY and CATCH.
TRY is just telling SQL Server that we want to try out something. CATCH tells SQL Server what to do if it completely messes up.
Read on to see how it works. As a quick note for those of you who come at this from a software developer’s background, T-SQL’s try-catch capabilities are not as robust as what you probably are used to, especially with respect to what gets caught. Most severe error messages are not catchable, so you can’t always expect that database query to go quietly in the night.