This chapter covers
- Handling T-SQL errors
- Troubleshooting code
- Performance testing
- Modern development practices
When one thinks of the role of a database developer, it is easy to focus exclusively on writing efficient T-SQL code. In reality, however, the modern database developer has to consider many other things. Error handling is the first of these areas. If a procedure throws an error in production, we will want that error to be handled gracefully to mitigate risks such as inconsistent data. Error handling can even make a piece of code retry to avoid an application support team having to step in. We will invariably also want to be notified if an error does occur so that it can be investigated.
We also need to be able to debug code errors efficiently. Code ends up with bugs. That is a fact of life. When there are bugs in our code, we need to be able to debug them in an efficient manner. There is no point in writing a piece of code in a day if it then takes a week to debug it. Therefore, understanding debugging methodology is essential when working with complex code.