I have been searching for this answer for quite sometime and so far, have not found a solution. I am creating a Data Flow Task in SSIS, and I need to join 2 tables on different data sources using the LIKE operator, or FINDSTRING, or CONTAINS etc.
Here is what my data looks like:
Table1 :: Data Source 1
| PersonName | Address |
Josh LA, California US
Ted SF, California US
Beth NYC, New York US
Table2 :: Data Source 2
| StateID | StateName |
01 California
02 New York
I need to join Table2 on Table1 where Table1.Address LIKE '%' + Table2.StateName '%'. My desired end result is this:
| PersonName | StateID |
Josh 01
Ted 01
Beth 02
I am doing this in SSIS, so Table1 and Table2 are gathered using an OLE DB Source component, now I need to find a way to perform a non-exact merge on those two tables.
- I cannot use a script component
I have tried using a "Lookup Transformation" where Table1 is the input to the Lookup. Then go to -> Advanced -> "Modify the SQL statement", and I have tried 2 things that have not worked:
1)
select * from (select * from [dbo].[Table2]) [refTable]
where ? LIKE '%' + [refTable].[StateName] + '%'
2)
select * from (select * from [dbo].[Table2]) [refTable]
where FINDSTRING( ?, [refTable].[StateName], 1) > 0
Is there any way to achieve what I am looking for in SSIS without using a script component? Maybe there is a way to use a fuzzy lookup? If so, how do I configure that? Is there like an advanced "Merge Join" object?