Ed Pollack shares several good T-SQL tips to simplify code:
While trying to solve the data challenges an organization throws our way, it is often easy to get buried in large, complex queries. Despite efforts to write concise, easy to read, maintainable T-SQL, sometimes the need to just get a data set quickly results in scary code that is better off avoided rather than committed.
This article dives into a handful of query patterns that can be useful when attempting to simplify messy code and can both improve query performance while improving maintainability at the same time!
Click through to learn more. I use most of those tips to great effect (though don’t often have need to hit some of the DMVs Ed mentions).