Introduction
Transact-SQL (T-SQL) is a powerful declarative language that lets you explore and manipulate your database. As the complexity of your programs increase, so does the risk of errors occurring, for example, from a data type mismatch, or variables not containing expected values. If not managed correctly, these errors can cause your programs to stop running or produce unexpected behaviors.
Here you'll cover basic T-SQL error handling, including how you can raise errors intentionally and set up alerts to fire when errors occur.
After completing this lesson, you'll be able to:
- Raise errors using the
RAISERRORstatement. - Raise errors using the
THROWstatement. - Use the
@@ERRORsystem variable. - Create custom errors.
- Create alerts that fire when errors occur.