【问题标题】:Using SSIS 2008 R2 to load only new data into an existing table from an excel (xls) file使用 SSIS 2008 R2 仅将新数据从 excel (xls) 文件加载到现有表中
【发布时间】:2011-10-12 04:47:04
【问题描述】:

我希望能够通过 SSIS 将数据从 excel 文件加载到 SQL Server 2008 R2 中的表中。但是,如果 Excel 源中未定义单元格值,则在数据加载期间不应更改原始表数据。 ID 列用于定义唯一记录。

以下是示例数据集,展示了所需的结果。

输入:

Excel File Format
+----+-------+-------+
| ID | Col_A | Col_B |
+----+-------+-------+
| 1  | apple |       |
| 2  |       | fork  |
| 44 | peach | knife |

Table - Before Data Load
+----+-------+-------+
| ID | Col_A | Col_B |
+----+-------+-------+
| 1  | pear  | spoon |
| 2  | orange|       |
| 3  | grape |       |

所需的结果表:(通过 SSIS 合并/更新到 SQL Server 2008 R2 后)

Table - After Data Load
+----+-------+-------+
| ID | Col_A | Col_B |  //Comments based on the tables perspective
+----+-------+-------+
| 1  | apple | spoon |  //Col_A updated based on excel dataset value; Col_B unchanged
| 2  | orange| fork  |  //Col_A unchanged; Col_B updated based on excel dataset value
| 3  | grape |       |  //No changes. ID was not defined in excel dataset
| 44 | peach | knife |  //New inserted row from excel dataset

非常感谢任何帮助。

【问题讨论】:

    标签: sql-server-2008 merge ssis


    【解决方案1】:

    您可以使用 SSIS 中的渐变维度任务来管理它

    【讨论】:

    • 也许吧。目前我倾向于使用 SQL Execute Task,它包含一个 MERGE 命令,在 UPDATE 中带有一个 COALESCE(source, target) (跳过源中的 NULL 值)。您如何看待这种方法?
    • 我也更喜欢在 T-SQL 中进行。通常我只使用 SSIS 将纯数据获取到数据库,然后使用 TSQL 进行处理。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    • 1970-01-01
    • 1970-01-01
    • 2020-11-17
    • 2018-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多