Refactoring Legacy T-SQL for Improved Performance

Modern Practices for SQL Server Applications

  • Lisa Bohm

Table of contents

  1. Front Matter
    Pages i-xxi
  2. Everything Is Slow

    1. Front Matter
      Pages 1-1
    2. Lisa Bohm
      Pages 3-19
    3. Lisa Bohm
      Pages 21-59
  3. Database Structure

    1. Front Matter
      Pages 61-61
    2. Lisa Bohm
      Pages 63-82
    3. Lisa Bohm
      Pages 83-105
  4. CRUD Objects

    1. Front Matter
      Pages 107-107
    2. Lisa Bohm
      Pages 109-135
    3. Lisa Bohm
      Pages 137-190
    4. Lisa Bohm
      Pages 191-218
  5. The Bad and the Ugly

    1. Front Matter
      Pages 219-219
    2. Lisa Bohm
      Pages 221-226
    3. Lisa Bohm
      Pages 227-232
  6. Back Matter
    Pages 233-236

About this book


Breathe new life into older applications by refactoring T-SQL queries and code using modern techniques. This book shows you how to significantly improve the performance of older applications by finding common anti-patterns in T-SQL code, then rewriting those anti-patterns using new functionality that is supported in current versions of SQL Server, including SQL Server 2019. The focus moves through the different types of database objects and the code used to create them, discussing the limitations and anti-patterns commonly found for each object type in your database.

Legacy code isn’t just found in queries and external applications. It’s also found in the definitions of underlying database objects such as views and tables. This book helps you quickly find problematic code throughout the database and points out where and how modern solutions can replace older code, thereby making your legacy applications run faster and extending their lifetimes. Author Lisa Bohm explains the logic behind each anti-pattern, helping you understand why each pattern is a problem and showing how it can be avoided. Good coding habits are discussed, including guidance on topics such as readability and maintainability. 

You will:
  • Find specific areas in code to target for performance gains
  • Identify pain points quickly and understand why they are problematic
  • Rewrite legacy T-SQL to reduce or eliminate hidden performance issues
  • Write modern code with an awareness of readability and maintainability
  • Recognize and correlate T-SQL anti-patterns with techniques for better solutions
  • Make a positive impact on application user experience in your organization


T-SQL Transact-SQL Performance Legacy Code Triggers Views Stored Functions Stored Procedures Indexes Query Tuning Subqueries Window Functions OVER Clause Temp Tables Temporary Tables Table Variables

Authors and affiliations

  • Lisa Bohm
    • 1
  1. 1.ChardonUSA

Bibliographic information

Industry Sectors
Chemical Manufacturing
IT & Software
Consumer Packaged Goods
Finance, Business & Banking
Energy, Utilities & Environment