Cross Apply and Outer Apply comes under Apply Operator which was introduced in SQL Server 2005.

Apply function allows to join a table to a table-valued function in such a way that function is invoked for each row returned from the table which you can't do with Join and is the main difference between Join and Apply:

Let's take an example to understand in more detail.

In the following example we have used split function (Table Valued Function) in which we would pass comma separated string and it would return a table.

Firstly, understand and create a split function before running the following snippet using the link : split function in SQL Server

  1. declare @tab table(Category varchar(20), item varchar(max))
  2. insert into @tab
  3. select 'Vegetables', 'Carrot,Tomato' union all
  4. select 'Fruits', 'Apple,Banana,Grape' union all
  5. select 'Beverages', null
  6. select t.Category, s.val as item
  7. from @tab t
  8. cross apply dbo.split(item, ',') s
  9. select t.Category, s.val as item
  10. from @tab t
  11. outer apply dbo.split(item, ',') s
OUTPUT

output

Look at the output.

Reason for difference

Function is returning null value for category "Beverages" because there is null value in item column for "Beverages".