Optimizing Transact-SQL Code
In previous articles we showed you how to optimize database models and indexes. We've also given you an overview of what it takes to keep a database in good shape. Getting the design right and maintaining the database will take you a long way, but won't prevent the problems that might stem from poor coding practices.
Learning T-SQL basics is relatively easy; however, just like any other programming language, T-SQL provides many good and some poor ways to accomplish the same task. In fact, there is so much to tuning T-SQL code that we don't dare attempt to cover it all in a single article. Instead, we'll discuss the basic concepts of writing good code and give you some tips for optimizing your code.