Understanding CROSS APPLY and OUTER APPLY in SQL Server


Introduction

When working with table-valued functions (TVFs) or subqueries, the CROSS APPLY and OUTER APPLY operators provide flexible ways to enhance SQL queries. While these operators might seem complex at first, understanding how they function can significantly improve both query performance and readability.

In this article, we will break down how each operator works with practical examples and clearly explain their behavior when using TVFs, a common scenario. We will also address common points of confusion to help you gain a solid understanding of these operators.

What are Table-Valued Functions (TVFs)?

A