The Working with APPLY Operator module provides you with the instructions and devices to develop your hands-on skills in the following topic.

  • Using CROSS APPLY and OUTER APPLY operators

Lab time: It will take approximately 30 minutes to complete this lab.

Exam Objectives

The following exam objectives are covered in this lab:

Demonstrate the use of Apply operators (CROSS APPLY and OUTER APPLY) in a Transact-SQL query to join a table to a table-valued function

Exercise 1 - Using CROSS APPLY and OUTER APPLY Operators

Transact-SQL APPLY operator joins a table and a user-defined Table-Valued Function (TVF). The left query constitutes the fields from the table, and the right query consists of the user-defined function that retrieves fields for each row of the table from the left query.

There are two forms of APPLY operator. These are as follows:

  • CROSS APPLY operator: It returns selective rows from the left query, where the function returns a non-empty result set. The CROSS APPLY operator excludes the rows where the function returns an empty set.
  • OUTER APPLY operator: It returns all the fields from the left query including the rows where the function returns an empty set.

In this exercise, you will learn to use CROSS APPLY and OUTER APPLY operators.

Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.