简体   繁体   English

使用SSIS将多个文本文件导入到多个表中

[英]Importing multiple text files into multiple tables using ssis

Q: I have multiple text files in a folder named xyz, and i have created a new database in sqlserver which does not having any tables .Here my problem is to import all those text files into new database according to the text file named tables using ssis package .can anyone knows please tell me the steps. 问:我在名为xyz的文件夹中有多个文本文件,并且在sqlserver中创建了一个没有任何表的新数据库。这里的问题是,使用名为table的文本文件将所有这些文本文件导入到新数据库中ssis软件包。谁能知道,请告诉我步骤。

A: Step 1: Use foreach loop iterator to pick all files in the specific folder. 答: Step 1: Use foreach loop iterator to pick all files in the specific folder.

Step 2: By using script task get the column name from text file and create the tables in you database. Keep the table name in the SSIS variable.

Step 3: Choose any destination task and insert the data into the newly created tables.

I used foreach loop container and selected the path of text files .in step 2 am unable to write the script for the column import .I have couple of text files named employee having columns id ,name and another one department having deptno ,location . 我使用了foreach循环容器,并选择了文本文件的路径。在第2步中,我无法编写用于导入列的脚本。我有几个文本文件,名为employee的列id ,name另一个,其中一个部门的deptno ,location Actually am a beginner to sql server and ssis too.can anyone knows please help me. 其实也是sql server and ssis初学者。谁能知道请帮助我。

  1. Take a look at this link , this will show you how to pick the files up 看看这个链接 ,它将向您展示如何挑选文件
  2. Within the ForEach Loop container , you will have a dataflow task . ForEach Loop container ,您将有一个dataflow task
  3. The source will be a Flat File Source which uses a Flat File Connection Manager . 源将是使用Flat File Connection ManagerFlat File Source The flat file connection manager will have an expression for the connectionstring which will be the variable populated in step 1. flat file connection manager将有一个expressionconnectionstring ,这将是在填充步骤1中的变量。
  4. The destination will be an OLE DB Destination , which will point to your table. 目标将是OLE DB Destination ,它将指向您的表。

NOTE : It might be easier to get the basic flow set up, with the FlatFile connection manager etc hard coded to one of the files. 注意 :将FlatFile连接管理器等硬编码到其中一个文件中,可能会更容易设置基本流程。 This will allow you to get the process working, and then you can introduce the ForEach loop and the variable/expression to make the process flexible. 这将使您能够使流程正常运行,然后可以引入ForEach循环和变量/表达式以使流程灵活。

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

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