Trapping Errors and Implementing Error Handling
When working with T-SQL batch processing, errors will occur. You can either learn to handle them or let them handle you. That means when writing your T-SQL scripts, you need to ask yourself, "What should the SQL code do if something goes wrong?" If your batch is a multi-step process and something goes wrong in the middle, should the batch reverse the previous statements, just end, or continue as if nothing happened? Learning how to detect, display, and respond to errors that might occur is very important to the programming process. In this section, you will learn how to use the available global variables that return error information in your SQL scripts.
Communicating Error Messages
When an error ...