简体   繁体   中英

SSIS Access DB data into TSQL with a stored procedure

I want to use a Data Flow Task that has two sources one from an Access DB and one from a SQL Server DB. I then want to manipulate the data and finally call a stored procedure on the same SQL Server that was my second source.

So I can't use an Execute SQL Task since I want to manipulate the data and call the stored procedure at the end.

What toolbox component would I use and what format would the stored procedure call?

I tried to do an OLE DB Destination with a stored procedure called something like this.

Exec sppUpdateAATable1 ?,?

SSIS uses concept of a pipeline to organise DataFlow task. Data flows from source to destination and processing of this data happens in between. Since you want to use the result of processing in your stored procedure as parameters, it cannot be done under pipeline concept. SP is not really a destination for your data, as SP will do something with it too.

You can populate an in-memory Recordset (destination), and use ForEach loop container to execute your SP for each row of recordset.

Update

You package should look something like this:

Data Flow task: OLE DB connection to Access OLE DB connection to SQL Server To combine 2 data streams use UNOIN task Record set destination, in properties you name a variable of type Object (MyRecordsetVar). It will hold recordset data.

ForEach Loop Container. In properties select type of loop container - ADO Recorset, specify MyRecordsetVar variable in loop properties. Assign two more (or as many as needed) variables to hold data from each column of the recordset. Data from each row of the recordset willbe passed to these variables. One row at a time.

Inside the loop put Execute SQL task. In Input "menu" of the task specify your INPUT variables - those that have data from columns of recordset. I would assume that you know how to do it.

Put your query into the task as execute sp_MyProc ?,? .

This should be it.

You can save yourself the trouble of the recordset destination and foreach loop route and instead use an OLE DB Command in your Data Flow. It's going to fire that stored proc for each row that flows through it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM