简体   繁体   English

如何使用SSIS将具有不同标头的多个csv文件导入数据库?

[英]How to import multiple csv files with different headers into database using SSIS?

I am writing a SSIS package to import multiple files in a folder with variation in the columns into a database. 我正在编写一个SSIS包,以将一个文件夹中的多个文件导入,数据库中的列会有所不同。 But cant find solution as one table has 12 columns and other 2 columns and while setting up the data flow not getting how to make the tables dynamic irrespective of the columns. 但是找不到解决方案,因为一个表有12列,其他2列,并且在设置数据流时没有获得如何使表动态(与列无关)的方法。 Any other solution better than SSIS is also appreciated 任何其他比SSIS更好的解决方案也值得赞赏

See the discussion in this link: Can SSIS import data from multiple files to multiple tables in loop? 请参阅此链接中的讨论: SSIS是否可以将数据从多个文件循环导入到多个表中?

You can use BCP or Bulk Insert to load files into different table. 您可以使用BCP或批量插入将文件加载到其他表中。

From you description: 根据您的描述:

database has fix number of tables which are same in every database, but the 18 tables have different columns.... for example: DB1 has [db1].[T1],[db1].[T2] DB2 has [db2].[T1],[db2].[T2] So [db1].[T1] structure is same as [db2].[T1] but [db1].[T1] has diff structure than [db1].[T2] 数据库具有固定数目的表,每个表中的表数目相同,但是18个表具有不同的列...。例如:DB1具有[db1]。[T1],[db1]。[T2] DB2具有[db2]。 [T1],[db2]。[T2]因此,[db1]。[T1]结构与[db2]。[T1]相同,但[db1]。[T1]的差异结构比[db1]。[T2]

What you need to do is to store File-Table mapping in a control table and then use Script Task to concatenate dynamic SQL Statement passed to Server. 您需要做的是将文件表映射存储在控制表中,然后使用脚本任务来串联传递给服务器的动态SQL语句。

样品

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

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