New ebook

Get my free book now!

Download the entire book as a PDF for free when you sign up for my mailing list. Feel free to unsubscribe at any time.

>>> Scroll to learn more!

    We respect your privacy. Unsubscribe at any time.

    “With the details in this book, I finally understand how common table expressions work. The WITH syntax finally makes sense to me.”

    What you get:

    You get full access to my Common Table Expressions book, along with sample code to support the queries shown in the book. You can download this as a PDF and start reading today.

    Over 250 pages of content all about TSQL and Common Table Expressions.

    CHAPTER 1. MEMORY TABLES

    CHAPTER 2. WHAT IS A COMMON TABLE EXPRESSION?

    CHAPTER 3. CTES INSTEAD OF DERIVED TABLES

    CHAPTER 4. RECURSIVE CTES

    CHAPTER 5. HIERARCHICAL CTES

    CHAPTER 6. MULTIPLE CTES IN A QUERY

    CHAPTER 7. DATA PAGING WITH CTES

    CHAPTER 8. MANIPULATING DATA

    CHAPTER 9. CTES IN FUNCTIONS, STORED PROCEDURES AND VIEWS

    CHAPTER 10. COMMON USE CASES

    CHAPTER 11. CTE PERFORMANCE CONSIDERATIONS

    CHAPTER 12. CTES FOR GEEKS – CLASSIC RECURSIVE ALGORITHMS

    This book was originally written in 2012, and has been updated in 2019 and 2022 for the latest versions of Microsoft SQL Server.

    What is it all about?

    The Common Table Expression (CTE) is one of the more powerful and often overlooked features in Microsoft SQL Server. This book will show some of the more interesting things you can do with a CTE. We will learn how CTEs are a great alternative to derived table queries, how to do data paging with a CTE and recursive queries with tree path and hierarchical output. This book will also cover how to use the DELETE, UPDATE, and INSERT statements with a CTE, and how to use CTEs in stored procedures and functions.

    We will discover what is good and bad with CTEs when it comes to performance and how to avoid performance pitfalls. The twelve chapters take us from the most basic introduction of a CTE all the way to the more complex usage scenarios where a CTE can change the way you look at writing T-SQL queries.

    Once you have mastered the CTE you may never look at a query the same again.