如何在 SSIS 中調用存儲過程? (How do you call a Stored Procedure in SSIS?)


問題描述

如何在 SSIS 中調用存儲過程? (How do you call a Stored Procedure in SSIS?)

I am trying to create an SSIS package that queries data from a table, and calls a stored procedure in another database with each row.

In my old DTS package, I was doing this:

EXEC myStoredProcedure ?, ?, ?

...and then I mapped the parameters.  However, in SSIS, I can't figure out how to make this work.

I have a Data Flow task, which first runs a query for the data.  It passes the data to an OLE DB Destination.  I set the Data access mode to "SQL command", but when I try to put in the SQL above, I get "Invalid Parameter Count" when it parses the SQL.  I can't get to the Mappings screen.  Any ideas?


參考解法

方法 1:

In the Data Flow, the OLE DB Command can be used to execute a SQL statement for each row in a dataflow - (MSDN documentation)

Alternatively, you can store the source result set in a variable of data type object and use a Foreach Loop container in the Control Flow (example here).

方法 2:

You will need to use an Execute SQL Task.  In the SQLStatement section you can add the code to execute the stored procedure. 

In order to pass in parameters, use the ? syntax and specify the parameters in the "Parameter Mapping" section.

A good example can be found here.

(by John BEd HarperLance Harper)

參考文件

  1. How do you call a Stored Procedure in SSIS? (CC BY-SA 3.0/4.0)

#sql-server-2005 #parameters #sql-server #stored-procedures #ssis






相關問題

可更新查詢所需的最低權限 (Access Project) (Minimum permissions required for an updatable query (Access Project))

Sql中的WHERE,結合兩個快速條件會成倍增加成本 (WHERE in Sql, combining two fast conditions multiplies costs many times)

是否可以重構此語句以刪除子查詢? (Is it possible to refactor this statement to remove the subquery?)

Không gửi được tệp nhật ký bằng 'Tác vụ Gửi Thư' từ trình xử lý OnError (Sending the log file using a 'Send Mail Task' from the OnError handler fails)

擴展 SSRS 中的圖表功能 (Extending chart functionality in SSRS)

sql server 2005 數據庫郵件錯誤(操作已超時) (sql server 2005 database mail error (The operation has timed out))

從.NET應用程序到SQL Server的緩慢調用 (Sporadically Slow Calls From .NET Application To SQL Server)

我需要在 sql 中獲取 alldata whereclause? (i need to get alldata whereclause in sql?)

一種檢查 SQL 2005 中是否存在外鍵的方法 (A way to check if foreign key exists in SQL 2005)

如何在 SSIS 中調用存儲過程? (How do you call a Stored Procedure in SSIS?)

什麼會使桌子“變慢”? (What would make a table "slow?")

可以在這裡使用 Common Table 表達式來提高性能嗎? (Can Common Table expressions be used here for performance?)







留言討論