Sunday, 4 November 2012

SQL Server CROSS APPLY and OUTER APPLY

Apply Operator In Sql Server

The APPLY operator allows you to join two table expressions; the right table expression is processed every time for each row from the left table expression. As you might have guessed, the left table expression is evaluated first and then right table expression is evaluated against each row of the left table expression for final result-set. The final result-set contains all the selected columns from the left table expression followed by all the columns of right table expression.

The APPLY operator comes in two variants:-
1. Cross Apply
2. Outer Apply

Cross Apply
The CROSS APPLY operator returns only those rows from left table expression if it matches with right table expression.

Outer Apply
OUTER APPLY operator returns all the rows from left table expression irrespective of its match with the right table expression.

No comments:

Post a Comment