Tải bản đầy đủ - 0 (trang)
2-1. Importing Data From a Text File

2-1. Importing Data From a Text File

Tải bản đầy đủ - 0trang

Chapter 2 ■ Flat File Data Sources



Figure 2-1.  Flat file sources in the Import/Export Wizard

5.



Click Columns, which shows you the list of available columns. Here you can change

specific column delimiters if you need to.



6.



Click Advanced. This lets you define the data type for each column. You can also set

the length, precision, or scale (depending on the data type)—or leave the defaults, as

shown in Figure 2-2.



64

www.it-ebooks.info



Chapter 2 ■ Flat File Data Sources



Figure 2-2.  Defining data types in the Import/Export Wizard

7.



Click Next. Check that the destination server, database, and authentication are

correct.



8.



Click Next. Ensure that the requisite destination table is selected.



9.



Click Next. Verify that Run Immediately is selected.



10.



Click Next, followed by Finish, then Finish again, and Close. Your data should be

correctly imported.



65

www.it-ebooks.info



Chapter 2 ■ Flat File Data Sources



How It Works

The Import/Export Wizard takes your flat file and assists you in defining its principal characteristics. You then

specify any more-advanced properties at the column level. If required, you can get this wizard to guess the

characteristics of the metadata in the source file.



Hints, Tips, and Traps





For the other ways of launching the Import/Export Wizard, see the Recipe 1-2.







You can ask the Import/Export Wizard to suggest data types for each column of data by

clicking the Suggest Types button. This is explained in more detail in Recipe 2-3.



2-2. Importing a Delimited Text File

Problem

You want to import a flat file on a regular basis and/or apply data transformation as part of a structured ETL

process.



Solution

Create an SSIS package to import the file. This is how you do it:

1.



Create a new SSIS project, or open an existing project, and add a new package.



2.



Add a Data Flow task onto the Control Flow pane. Edit this task by doing any of the

following:



3.







Double-click.







Right-click and select Edit.







Click the Data Flow tab.



Add a Flat File source from the Data Flow sources in the toolbox. Double-click the Flat

File source to edit it. You should see the dialog box shown in Figure 2-3.



66

www.it-ebooks.info



s



Figure 2-3. Flat File Source Editor in SSIS

4.



Click New to specify the file connection, which opens the File Connection Manager

Editor. Browse to select the source file (or type it in if you prefer). In this example,

it is C:\SQL2012DIRecipes\CH02\Invoices.Txt. Specify whether column names

are in the first row, enter the text qualifier, and select the row delimiter (or leave the

defaults). You should end up with something like what you see in Figure 2-4.



67

www.it-ebooks.info



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

2-1. Importing Data From a Text File

Tải bản đầy đủ ngay(0 tr)

×