0

Details (this is specific to SSIS) : There are two database servers : A & B I have to fetch list of few values from database A (like 1,2,3,4,5 in one column) and pass it in the "IN" clause to a command that will run on database B (like Select something from B.Table where column in (1,2,3,4,5)).

The "Execute SQl task" result set is mapped to an object variable X, which cannot be passed directly as a parameter to the second command.

What are the possible solutions to this?

Jim
  • 355
  • 7
  • 20

1 Answers1

0

One possible solution is to use a Script Task to iterate through the Object Variable and build a SQL String to be used in the second Execute SQL task.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52
  • In that case i assume you are suggesting dynamic sequel because in the in-clause" normal string parameter is taken as a string (one value) rather than being taken as a comma separated int values. Is it possible to use dynamic sequel in a task? – Jim May 23 '16 at 16:06
  • Not exactly dynamic sql. Populate a package variable with your entire SQL String, dynamically building the IN clause in the script task. Then in the next Execute SQL task, choose the SQL From Variable option, and use your SQL String variable. – Tab Alleman May 23 '16 at 17:08
  • That solved the issue. Although i did not want to touch the sql command that was supposed to run on server B, rather just substituting it somehow, but anyways it helped move further. Thank You. :) – Jim May 24 '16 at 06:16