Advanced Lookup Transformations in SSIS

By Tom Nonmacher

In the world of data integration and transformation, lookup transformations are one of the most commonly used tasks. SQL Server Integration Services (SSIS) provides a powerful and flexible platform for performing these operations. In this blog post, we will dive into some advanced lookup transformations using SSIS on SQL Server 2016 and SQL Server 2017, MySQL 5.7, DB2 11.1, and Azure SQL.

Firstly, let's talk about what lookup transformations are. In simple terms, lookup transformations are used to supplement data in an input column by referencing data in another dataset. This operation can be compared to a SQL JOIN operation. The input column is matched to a lookup dataset, and if a match is found, the corresponding values from the lookup dataset are returned. SSIS offers two types of lookup transformations: the standard Lookup transformation and the Fuzzy Lookup transformation.

The standard Lookup transformation in SSIS performs an equi-join between values in the transformation input and values in the reference dataset. It is a straightforward and efficient way to perform lookups. Here is how you can perform a standard lookup transformation in T-SQL for SQL Server 2016 and 2017:


-- T-SQL code for standard lookup transformation
SELECT A.Col1, A.Col2, B.Col3
FROM Table1 A
INNER JOIN Table2 B
ON A.Col1 = B.Col1

Next, let's discuss the Fuzzy Lookup transformation. This transformation provides an advanced way to perform lookup operations, especially when dealing with unclean data. The Fuzzy Lookup transformation uses fuzzy matching to return one or more close matches in the reference table and to include these matches in the output. Here is an example of how you can perform a fuzzy lookup transformation in T-SQL:


-- T-SQL code for fuzzy lookup transformation
SELECT A.Col1, A.Col2, B.Col3
FROM Table1 A
CROSS APPLY (
    SELECT TOP 1 B.Col3
    FROM Table2 B
    WHERE CONTAINS(B.Col1, A.Col1)
) B

For MySQL 5.7 and DB2 11.1, you should note that they do not natively support fuzzy lookup transformations like SSIS does. However, you can use the SOUNDEX function or the Levenshtein distance function to achieve similar results. Here is how you can perform a fuzzy lookup transformation in MySQL 5.7:


-- MySQL code for fuzzy lookup transformation
SELECT A.Col1, A.Col2, B.Col3
FROM Table1 A
INNER JOIN Table2 B
ON SOUNDEX(A.Col1) = SOUNDEX(B.Col1)

Finally, let's talk about Azure SQL. Since Azure SQL is essentially SQL Server running on cloud, lookup transformations can be performed much the same way as on SQL Server 2016 and 2017. However, you should be aware of the potential latency issues when performing lookup transformations on large datasets in Azure SQL. To mitigate this, you can use the Partial Cache or the No Cache option in SSIS.

In conclusion, lookup transformations are a vital part of data integration and transformation tasks. Whether you are using SQL Server, MySQL, DB2, or Azure SQL, understanding how to perform advanced lookup transformations can significantly enhance your data integration and transformation capabilities.




D8F86E
Please enter the code from the image above in the box below.