SSIS Compare tables content and update another

断了今生、忘了曾经 提交于 2019-12-13 03:46:57

问题


I would like to compare two tables, one from Access Mdb & one SQL server table is SSIS.

The goal is to truncate the table if there is differences and fill it with MDB source and Update the version in another table.

I am trying to do it through a lookup but the Version is incremented with the number of rows and it should be once.

The operation needs to be performed with 2 different Tables.


回答1:


How am I supposed to perform only once the update even if I have 10 No Match output rows ?

SSIS provides the OLEDB Command for performing in the pipeline updates in a data flow. However, as you have implied in your question, this performs an UPDATE command per row.

A more efficient technique for performing batch level updates is to:

  1. Truncate UPDATE staging table
  2. Detect what rows have changed in the data flow
  3. Direct changed rows to a destination and store the data in a staging table
  4. Add an execute SQL command after the data flow which will perform an update from the staging table to the target table. i.e.

    UPDATE T
    SET T.Column1 = S.Column1
        , T.Column2 = S.Column2
    FROM MyTarget T 
        JOIN MySource S ON T.id = S.id
    

The Control flow will look like this:

EDIT: Edited Steps and image to add a step for truncating the staging table.



来源:https://stackoverflow.com/questions/28429881/ssis-compare-tables-content-and-update-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!