使用SSIS 2008 R2仅将新数据从excel(xls)文件加载到现有表中

时间:2011-10-12 04:47:04

标签: sql-server-2008 merge ssis

我希望能够通过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

任何帮助非常感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用SSIS中的Slowly Changing Dimension任务来管理