Search code examples
sql-serverssisssis-2012

How to control which rows were sent via SSIS


I'm trying to create SSIS package which will periodically send data to other database. I want to send only new records(I need to keep sent records) so I created status column in my source table.

I want my package to update this column after successfuly sending data, but I can't update all rows wih "unsent" status because during package execution some rows may have been added, and I also can't use transactions(I mean on isolation levels that would solve my problem: I can't use Serializable beacause i musn't prevent users from adding new rows, and Sequence Container doesn't support Snapshot).

My next idea was to use recordset and after sending data to other db use it to get ids of sent rows, but I couldn't find a way to use it as datasource.

I don't think I should set status "to send" and then update it to "sent", I believe it would be to costly.

Now I'm thinking about using temporary table, but I'm not convinced that this is the right way to do it, am I missing something?


Solution

  • Record Set is a destination. You cannot use it in Data Flow task. But since the data is saved to a variable, it is available in the Control flow.

    After completing the DataFlow, come to the control flow and create a foreach component that can run on the ResultSet varialbe. Read each Record Set value into a variable and use it to run an update query.

    Also, see if "Lookup Transform" can be useful to you. You can generate rows that match or doesn't match.

    I will improve the answer based on discussions