Have you ever been faced with the SSIS error “Row yielded no match during lookup”? If so, this blog is for you!
A customer of ours recently faced the same issue in one of their SSIS packages and asked us to investigate this for them. Initial investigations on their side highlighted that when they replicated the lookup component using a standard join in T-SQL (similar to the image below) it returned the expected results.
So why was SSIS reporting an error and ultimately causing the package to fail?
To demonstrate why they faced this problem, I will provide a worked example. It should be noted that the customer example we were presented with was many thousands of rows, so the problem was much less obvious than the one I have created today.
To begin with, I have created 3 tables in my demo database using a subset of Adventure Works data.
“example.Product” which contains 10 rows and 4 columns. Essentially this could be thought of as my Product Dimension.
“example.Sales” which contains 40 rows and 4 columns. Essentially this could be thought of as my Staging Fact Table.
And finally, “example.FactSales” which contains 40 rows and 4 columns and is the result of the lookup component and ultimately would form the basis of my Sales Fact Table.
Here you will notice that “ProductNumber” has been replaced with “ProductKey”. Behind the scenes in my example SSIS package I am looking up “ProductNumber” from the “example.Product” table to return “ProductKey” in my Sales Fact Table.
*Note: I have specified for the component to fail if it finds any none matching rows.
Below is the data flow task within my example SSIS package.
This package executes without failure and populates my “example.FactSales”. However, I will now replicate the issue our customer in question faced.
To begin I executed the below T-SQL update statement against my “example.Product” table.
This changed the “ProductNumber” from “AR-5381” to “ar-5381” where “ProductKey” was equal to 1. When performing a simple “SELECT TOP 100 * FROM example.Product” we can now see that “ProductNumber” is lower case where “ProductKey” = 1 and the rest of the Product Numbers remain unchanged.
Now when I replicate the existing SSIS package using a standard T-SQL join as before there appears to be no issue – 40 rows are still returned using an inner join.
However, if I now execute the SSIS package the error “Row yielded no match during lookup” is subsequently returned.
So why is this happening?
Quite simply SSIS is case sensitive, accent sensitive and kana sensitive (at least in full cache mode) whereas SQL Server is not.
Now this is a fairly obvious example, but with more complex lookups which may involve multiple columns, it becomes a little more tricky to spot!
To solve this customer example, I used the EXACT function in MS Excel to spot the exact row in the lookup table which was returning the error. The EXACT function compares two text strings and returns “TRUE” if they are exactly the same and “FALSE” if they are not.
Alternatively, you could use SQL Server itself to replicate the lookup behavior of SSIS. Taking the T-SQL script from before, you can alter the existing inner join to a left join and collate using “Latin1_General_BIN” to identify the potential root cause of the lookup failure.
This highlights the importance of cleaning and standardising your lookup columns before using an SSIS lookup data flow component. Here at Purple Frog we tend to use a scalar function to create clean derived columns which are subsequently used for lookup components.
I hope this helps you solve any “Row yielded no match during lookup” errors with your SSIS solution!