In my source system (table), I have all the product with their details. Somehow I have products which belongs to the country which doesn’t exist in my reference (master) table. I assigned a job to rectify those products. I need to design ETL which gives me those records whenever we import products to our target database (table). So here, I am going to use “Lookup no match output” to capture those records by following steps:
Let’s take an example to easily understand how to use Lookup Transformation in SSIS.
1. Create Source Connection:
Select and drag “Data Flow Task”, from “Control Flow Items” to designer surface. Then double click it and Create a New OLEDB connection.
2. Create sample tables
Now we will create tables named ‘LKP_Countries_Source’ and ‘LKP_Countries’ into Test Database from the given script.
3. Create Lookup connection:
Now you Need to select the proper OLEDB connection in “Connection Manager” tab and the source table for lookup task.
4. Columns Selection from Source Table:
Select the columns to use as output columns.
5. Lookup Transformation Editor:
Here, I have added “Lookup Data Transformation” Task to designer tab and click on edit to configure the Lookup transformation.
6. Handle No Match output:
Now we need to configure various sections in the “Lookup Transformation Editor”.
In General section, select “Redirect rows to no match output” to handle the unmatched data from the lookup task.
Here we will need to select Cache mode as “Full Cache”. This option is used to improve the performance while handling large scale of data.
Keep connection type as “OLEDB Connection Manager”, as we are using OLEDB source. When you use Cache File as data source then you will need to select “Cache Connection Manager”
Last option provide various ways in which not matched data can be handled.
7. Set Connection Manager for Lookup table:
In Connection section select the reference table with proper connection. This list will get compared with source dataset for matching the data.
8. Column mapping for Lookup table:
In Columns section, select the available input columns and map it with the available lookup columns. This will create a join between 2 source datasets.We have used “Full Cache Mode”, so Advanced section will be disabled and in “Error Output” keep fields as it is.
9. Input Output Selection Setup:
Select new “OLEDB Destination” transformation and drag it to the designer surface. Drag green arrow from “Lookup Transformation” Task to “OLEDB Destination” and provide “Lookup Match Output” as Output and click OK.
10. Create Output table for Match and Not Matched Data:
Now we will need to create output tables to store the matched as well as not matched result.
11. Data Mapping for Result table:
Now I need to provide mapping for the Output Table to store the Matched Data.
12. Complete Data Flow for Lookup Transformation:
In order to handle the “Not Matched data”, provide the link of Not Matched data to OLEDB Destinationtable “LKP_Output_No_Match”. It will store the not matched results.
13. Package Execution and Result:
Now let’s execute the Package and check with the output inside the tables we have created to store the result as in
“LKP_Output_Match” table for Matched Data and “LKP_Output_NO_Match” table for Not Matched Data.
Lookup Transformation can be used in various ways according to the requirements and can be implemented accordingly. This was just an understanding document for Lookup Transformation.
Posted by Tejas Shah on November 22, 2017
Posted by Tejas Shah on November 11, 2017
Posted by Tejas Shah on August 12, 2015
Posted by Tejas Shah on June 26, 2015
Posted by Tejas Shah on April 20, 2015