Execute stored procedure for each row in the table in SSIS

我是研究僧i 提交于 2019-12-10 18:19:25

问题


I would like to execute a stored procedure MyProc with certain input parameters for each row in the table MyTable. Column for each row will act like input values for MyProc.

How do I accomplish this in SSIS? I have been told by upper management to use SSIS and I don't have any choice in this matter.

So.. I have done the following:

  1. Create package
  2. Create Execute SQL Task
    • Created query inside ExecuteSQLTask
  3. Create Foreach Loop Container
    • Create Data Flow Task inside Foreach loop container.
    • Inside Data Flow Task I created OLE DB Source
    • Connected OLEDBSource to Derived Column
    • Enable DataViewer in connection in step 3.3

It looks like the DataFlowTask in step 3.1 is being called for all rows in step 2.1

What I want is to invoke DataFlowTask in step 3.1 to get called for each record in the row in step 2.1 AS OPPOSED TO all the records.

Once this works, then I intend to ExecuteSQLTask inside a ForEachLoopContainer.


回答1:


All you need is a Dataflow Task with an OLEDB source and an OLE DB Command transformation.

The OLEDB source SELECTs from the table that you want to perform the row-by-row stored procedure on.

It then is followed by an OLE DB Command transformation that calls the stored procedure and passes columns from the data flow to the parameters of the stored procedure.

This will result in the stored procedure being executed once for each row of your table. You don't need the initial Execute SQL, and you don't need the For-Each loop.



来源:https://stackoverflow.com/questions/29520255/execute-stored-procedure-for-each-row-in-the-table-in-ssis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!