0

I am pretty new to SSIS and below is the SQL query which explains what I am trying to do:

select * from Table1 t1 join 
(Select ID, LEN(ID) as len from Table2) as t2
on RIGHT(RTRIM(t1.col) , t2.len) = t2.ID

There might be some better query in SQL for the same but I am intrested as how to implement this logic in SSIS?

I need to find all the records from table 1 where the col (from the right) matches with the ID value retrieved from table 2.

4
  • Can you explain more about what you need to be able to do? You can execute SQL from SSIS, so as far as I can tell so far, that's your answer. Apr 28, 2015 at 13:52
  • @TabAlleman Is there no way (any data flow transformation) to do this without executing SQL from SSIS? Table 2 has a ID column which is a string. Column col in Table 2 is the concatenation of 3-4 strings with the last string as the value of ID from table1. This is the data available to me and now I need to find the records from Table 2 which has the match for ID from table2.
    – AB_87
    Apr 28, 2015 at 22:41
  • Why not do it in the sql that generates your Source transformation? There is still not enough detail here about your needs. Are the two tables on the same server? Are they both on either the source or the destination server? Are you migrating data from only one table or both? Which one? Apr 29, 2015 at 13:18
  • @TabAlleman I can use SQL query, but I wanted to know how to do it with some other data flow transformation. Got the answer from Mike. Thanks
    – AB_87
    May 7, 2015 at 2:02

1 Answer 1

1

I would use an SSIS Lookup task using the Partial Cache option: https://msdn.microsoft.com/en-us/library/ms137820.aspx

This will execute the specified SQL statement row-by-row. The SQL statement design would essentially be what you have coded in your question - getting SQL to do the complex join requirement.

For performance reasons, I usually have to edit the generated SQL (see step 12 on that page) to remove the outer derived table SELECT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.