--

CROSS APPLY is a table operator in SQL Server that allows you to apply a table-valued function to each row of a table or view. In the first query, it is used with the STRING_SPLIT function to split the toppings column's values (which are comma-separated) into individual rows.

For each row in the pizza_runner.pizza_recipes table, CROSS APPLY applies STRING_SPLIT to the toppings column, creating a new virtual table where each topping ID is a separate row.

And it is different from CROSS JOIN with is a Cartesian product of two tables. it combines every row from the first table with every row from the second table.

--

--