4

我有一张 Excel 表,其中包含必须保存在 4 个表中的信息。我必须为每个表创建唯一的 id。我还必须将一些数据插入表 1,然后在那里创建的唯一 id 将用于将数据插入第二个表(参考完整性)。此外,一张表将始终插入要插入的记录,但对于其余 3 张表,如果某些数据已经存在,则必须对其进行更新而不是插入。我是 SSIS 的新手,所以请指导我如何在 SSIS 中继续前进。

4

2 回答 2

0

loads of requirements :)

First, here is an example of a package that loads an excel sheet to a sql database. You can easily follow it to build your package.

Differences:

You say you need to insert the same data on 4 tables, so between your excel source and your destination, you will add a multicast component and them instead of 1 destination, you will have 4. The "multicast" will create 4 copies of your data, so you can insert into your 4 tables.

The IDs may be a problem, since the 4 destinations will execute separately, you cant get the ID inserted on the first table to update the second. I suggest you do it using a T-SQL on a "Execute SQL task" after everything is imported .

If that is not possible you will need to have 4 separately data flows where on each one you do the inserts reading from your excel and joining with the result of the previous insert with a lookup task

于 2012-05-14T09:45:01.003 回答
0

将其导入到 SQL 服务器上的 Temp 表中。然后,您将能够编写一个从 Temp 表检索到多个表的查询。

希望这可以根据您的要求解决您的问题。

于 2013-12-12T12:50:54.713 回答