Cross apply and outer apply in sql server



cross apply sql server example
sql server outer apply example
sql server join table function with parameter
sql server inner join table valued function

In this video we will discuss cross apply and outer apply in sql server with examples.

We want to retrieve all the matching rows between Department and Employee tables.

This can be very easily achieved using an Inner Join as shown below.
Select D.DepartmentName, E.Name, E.Gender, E.Salary
from Department D
Inner Join Employee E
On D.Id = E.DepartmentId

Now if we want to retrieve all the matching rows between Department and Employee tables + the non-matching rows from the LEFT table (Department)

This can be very easily achieved using a Left Join as shown below.
Select D.DepartmentName, E.Name, E.Gender, E.Salary
from Department D
Left Join Employee E
On D.Id = E.DepartmentId

Now let’s assume we do not have access to the Employee table. Instead we have access to the following Table Valued function, that returns all employees…

sql tutorial for beginners with examples