Emil
Emil

Reputation: 6893

filtering rows with an select in query

I generate variable as object from a resulset of a SQL task. SQL task is basically a select myID from myTable query.

What I need to do is I have to filter other table using those IDs returned in the other one. I use an conditional split in the task flow but how can I achive to make it like an "Select In query" on tsql. what I mean is select from table2 where myOtherID in (x,y,z)

those x,y,z are as integer and should be what it is returned by the first query which are hold in my VarIds object variable.

thanks for you help.

Upvotes: 0

Views: 57

Answers (1)

James Rosser
James Rosser

Reputation: 424

You can pass the variable into a script task to loop over the values and transform your Result Set into a query in the form of a string.

Once you have your string query saved to a variable you can create a data flow task later in the control flow. It needs to start with an OLEDB source shape which will perform your select query.

In the OLE DB Source Editor set the Data Access Mode drop-down to "SQL command from variable" and select your variable.

That should do it.

Upvotes: 1

Related Questions