Please read Update1 first! This is SSIS specific question.
I have the following tasks:
- I need to periodically move data from table A in MySQL to Table B in MsSQL.
- Then all of the moved rows needs to be updated in Table A (change a single column value).
I have accomplished task 1 by creating the following Data Flow: ADO NET Source -> Data Conversion -> SQL Server Destination. It’s working great. I run this query X minutes.
Now, using SSIS tool, how do I update the rows that I just “Data Flow”‘ed in MySQL? If I was to use a plain SQL I’d do (in MySql):
update table mytable set status=”moved” WHERE …
(this will make sure that next time task 1 pulls the data out – it skips all rows that were already “moved”)
So the problem is that I don’t know how to connect WHERE clause in the 2nd task with the resultset of the 1st task.
Update1: I’m not so interested in optimizing the update procedure. I have simplified it here to put emphasis on the the question: How to implement this in SSIS. I’m specifically interested in what kind of Data/Control Flow blocks in SSIS I need to use what is the sequence.
I find that the easiest is to have an intermediate status like:
status = 1UPDATE myTable SET status = 2 WHERE status = 1AFTER YOUR UPDATE:
You could use Multicast just before your destination and capture IDs of records transferred over into another table
CapturedRowsin the source DB. After that use Execute SQL Task to update rows in a source table, like:After this you would use another Execute SQL Task to truncate the
CapturedRowstable.You could also connect OLE DB Command to the Multicast directly, to update records one by one, as they flow — but that would be quite slow.
To use this, you would have to set Fail Package On Failure for the Data Flow Task to make sure that it stops if an insert fails and Transaction Option for package to required and for the Data Flow to supported.