简体   繁体   English

如何通过使用SSIS将数据从多个表插入到多个表?

[英]How to insert data from multiple tables to multiple tables by using SSIS?

I am using SQL Server 2008 R2. 我正在使用SQL Server 2008 R2。 I have almost 106+ tables in database and now I need to load data from these tables into another database. 我的数据库中有近106个表,现在需要将这些表中的数据加载到另一个数据库中。

Table structure of source and destination database are same. 源数据库和目标数据库的表结构相同。 There is a status table in the database and all tables have a Primary Key ID field. 数据库中有一个状态表,所有表都有一个“主键ID”字段。 All the tables have Primary key and Foreign key relationship. 所有表都具有主键和外键关系。

Status table contain the ID field of tables and anther column contain a status of related ID field that this ID has completed its task. 状态表包含表的ID字段,而花药列包含该ID已完成其任务的相关ID字段的状态。

I need to transfer data those ID number will match with Status table where ID status is 1 or something like this. 我需要传输那些ID号与ID状态为1或类似这样的Status表匹配的数据。 I need to insert Identity column also, and because of all the table have PK and FK relationship so i have to insert data into tables with referential constraints. 我还需要插入Identity列,并且由于所有表都具有PK和FK关系,因此我必须将数据插入具有参照约束的表中。

So, my questions here is: To fulfill my above scenario how can I load data from multiple tables to multiple tables by using SSIS because it is not one time thing. 因此,我的问题是:为了实现上述情况,我如何通过使用SSIS将数据从多个表加载到多个表中,因为这不是一次性的事情。

Status table idea is not clear.i hv 160+ tables then status table will contain what ? 状态表的想法还不清楚.i hv 160+表然后状态表将包含什么? give example. 举个例子。

Of course you hv to start with diagram/flow 当然,您要从图表/流程开始

suppose 假设

table1 id pk
table2 id pk (table1 id fk)
table3 id pk (table2 id fk)

insert into table1
insert into table2
insert into table3

In my example you can't first inert into table3 becasue of FK constraint. 在我的示例中,由于FK约束,您不能首先对table3进行惰性处理。 This way first you hv to make flow. 首先,您要通过这种方式使流程顺畅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM