The Full Outer Join in SSIS is similar to SQL Full join, which returns all the records present in both the Left table and the right table. All the Unmatched rows will fill with NULL Values.
In this article, we are going to perform Full Outer Join in SSIS Merge Join Transformation. Please refer to Left Outer article to understand Left Outer Join using Merge Join Transformation. And refer to Right Outer article to understand Right Outer Join
Before we start creating the Package, let us look at our two source tables on which we are going to perform SSIS Full Outer Join using Merge Join Transformation.
Employees Table inside the following Database is:
Department Table inside the Database is:
Full Outer Join in SSIS Merge Join Example
To perform Full Outer Join in SSIS, Drag and drop the data flow task from the toolbox to the control flow region. Next, rename it as Performing Full Outer Join Using Merge Join Transformation in SSIS
Double click on the data flow task will take us to the Data flow region.
Drag and Drop two OLE DB Sources from the toolbox to the data flow region. Then double-click on the first OLE DB source in the data flow region will open the connection manager settings. And it provides an option to select the table holding the source data.
From the above screenshot, you can observe that We selected [Employees] Table from the Database
Click on the columns tab to verify the columns and uncheck the unwanted columns.
Double click on the second OLE DB source to configure the Second table to perform Merge Join. Here we are selecting the [Department] Table from the Database
Click on the columns tab to verify the columns.
Before we apply the SSIS Full outer join, we have to use sort transformation. So, Drag and drop two Sort Transformations from the toolbox to the Data Flow region. Next, connect the OLE DB Source output arrow to the Sort Transformation.
Double click on Sort Transformation to configure it. Check the columns we want to sort, and don’t forget to Pass Through the remaining column. If you ignore them to Pass Through, they won’t appear in output columns.
From the source data, DepartID is the Joining key between Employees and Department tables. So we are sorting the Employees table by DepartID in ascending order.
TIP: Merge Join Transformation will not work without sorting the input rows. So Sort Transformation is mandatory before applying Merge Join Transformation.
Double click on Sort Transformation 1 and sort the Department table using the id column in ascending order.
SSIS Full Outer Join
Now drag and drop the Merge Join Transformation into the data flow region to perform Full Outer Join in SSIS on the sorted tables.
When you drag the output arrow of the Sort Transformation into Merge Join Transformation, an Input Output Selection window appeared to select whether it is Merge Join Left Input or Merge Join Right Input.
Here we selected Merge Join Left Input for Employees table. Click ok and drag and drop the output arrow of the Sort Transformation 1. Here Merge Join Right Input automatically selected by the intelligence.
Double click on Merge Join Transformation will open the Merge Join Transformation Editor to configure it.
Join Type provides a drop-down list to select the Join type (such as Inner Join, Left Outer Join, and SSIS Full Outer Join) you want to perform on the source data. In this example, we are performing SSIS Full Outer Join. That’s why we selected the Full Outer Join option from the Join Type option.
As you know from the source data, both Employees and Department tables are joined using DepartID and id columns. So select them as Join keys of the SSIS Full outer Join by dragging the arrow.
Now select the columns you want to send to the destination table (Pass through columns) by check-marking the column names.
From the above screenshot, you can observe that, We selected [First Name], [Last Name], and [Department Name] columns as output columns.
It means SSIS Full Outer Join will produce all the rows from [First Name], [Last Name], and [Department Name] columns. All the non-matching rows treated as NULL.
TIP: Whatever columns you select here will only store in the destination table. If you don’t want any column, then uncheck that column.
STEP 10: Drag and drop the OLE DB destination into the data flow region and double-click on it to configure the destination server and destination table to store the Merge Join Transformation output
Here we selected the database and [Full Outer Join Using Merge Join Transformation] as the destination table
STEP 11: Click on the columns Tab to check whether input columns are matching with the destination columns or not. If not, Please assign the appropriate columns to destination columns
We finished designing the Performing Full Outer Join in SSIS Merge Join Transformation package. Let us execute the package
Now let’s open the Management Studio and select the columns from [Full Outer Join Using Merge Join Transformation] table.