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.
我正在尝试创建一个SSIS包来查询表中的数据,并在每行的另一个数据库中调用存储过程。
In my old DTS package, I was doing this:
在我的旧DTS包中,我这样做:
EXEC myStoredProcedure ?, ?, ?
...and then I mapped the parameters. However, in SSIS, I can't figure out how to make this work.
...然后我映射了参数。但是,在SSIS中,我无法弄清楚如何使这项工作。
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?
我有一个数据流任务,它首先运行数据查询。它将数据传递到OLE DB目标。我将数据访问模式设置为“SQL命令”,但是当我尝试输入上面的SQL时,我在解析SQL时得到“无效参数计数”。我无法进入Mappings屏幕。有任何想法吗?
2 个解决方案
#1
13
In the Data Flow, the OLE DB Command
can be used to execute a SQL statement for each row in a dataflow - (MSDN documentation)
在数据流中,OLE DB命令可用于为数据流中的每一行执行SQL语句 - (MSDN文档)
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).
或者,您可以将源结果集存储在数据类型对象的变量中,并在控制流中使用Foreach循环容器(此处为示例)。
#2
8
You will need to use an Execute SQL Task. In the SQLStatement section you can add the code to execute the stored procedure.
您将需要使用执行SQL任务。在SQLStatement部分中,您可以添加代码以执行存储过程。
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.
这里可以找到一个很好的例子。
#1
13
In the Data Flow, the OLE DB Command
can be used to execute a SQL statement for each row in a dataflow - (MSDN documentation)
在数据流中,OLE DB命令可用于为数据流中的每一行执行SQL语句 - (MSDN文档)
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).
或者,您可以将源结果集存储在数据类型对象的变量中,并在控制流中使用Foreach循环容器(此处为示例)。
#2
8
You will need to use an Execute SQL Task. In the SQLStatement section you can add the code to execute the stored procedure.
您将需要使用执行SQL任务。在SQLStatement部分中,您可以添加代码以执行存储过程。
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.
这里可以找到一个很好的例子。