Tải bản đầy đủ - 0 (trang)
5-15. Loading Data into SQL Server Azure as Part of a Regular ETL Process

5-15. Loading Data into SQL Server Azure as Part of a Regular ETL Process

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

Chapter 5 ■ SQL Server Sources



Figure 5-9.  SSIS and .NET connection to SQL Server Azure



274

www.it-ebooks.info



Chapter 5 ■ SQL Server Sources



3.



Add a new Data Flow task to the Control Flow pane. Double-click to edit.



4.



Add an OLEDB Data Flow source, double-click to edit, and configure as follows:

OLEDB Connection Manager: Source_OLEDB

Data Access Mode:



SQL Command



SQL Text:



SELECT



ClientName, Country, Town, County,

Address1, Address2, ClientType, ClientSize



FROM

5.



Add an ADO.NET destination. Connect the OLEDB source.

Connection Manager:

Use a table or view:



6.



dbo.Client



Azure_ADONET

"dbo"."Client"



Click Mappings and map all the columns between the source and the destination.

Click OK to confirm your modifications.



How It Works

This process is virtually identical to a “standard” SSIS package used to load data into SQL Server. This is because

SSIS SQL Server Azure is a (largely) normal data source or destination. Indeed, Azure supports both ADO.NET

and OLEDB connection managers. However, the only slight difference is that you cannot select the database

name, but must enter it in the database name pop-up list. In a real-world scenario, you will inevitably need

an SSIS configuration file (or another configuration method) to store the password used to connect to the SQL

Server Azure database.



Hints, Tips, and Traps





You can also use an OLEDB destination if you prefer. This means configuring an OLEDB

connection manager for the Azure database. It is identical to the ADO.NET connection

manager except in one respect—the username must also have @ServerName appended,

as shown in Figure 5-10.



275

www.it-ebooks.info



Chapter 5 ■ SQL Server Sources



Figure 5-10.  OLEDB connection to SQL Server Azure in SSIS





While it is possible to use SSIS to create the destination tables, I recommend scripting

and creating the requisite DDL using SSMS, as it helps to avoid the pitfalls that can trip up

the unwary developer when moving to SQL Server Azure. One such trap is the absolute

requirement for a clustered index, which SSIS does not add for you and then causes the

data load to fail. Otherwise, remember to create a clustered index after you have created

the table using SSIS.







You can use any data source that you would use normally to load data into SQL Server

Azure. You can use SSIS to its full potential to transform the data.







An Azure connection manager can be defined at package level if you are using SQL Server

2012. Also available, since SSIS for SQL Server 2008 R2, is the “Use bulk insert when

possible” option, which speeds up larger data loads.



276

www.it-ebooks.info



Chapter 5 ■ SQL Server Sources



5-16. Loading Data into SQL Server Azure from

the Command Line

Problem

You want to load data into SQL Azure quickly and easily from the command line.



Solution

Load data into SQL Server Azure using BCP.

Providing that you have the version of BCP starting with SQL Server 2008 R2, you can load data into SQL

Server Azure.

1.



Create a BCP export file, preferably in SQL Server native or widenative format, as this

removes the need for format files.



2.



Run the following BCP command:

C:\Users\Adam>BCP Carsales.dbo.client IN C:\SQL2012DIRecipes\CH05\Azure.BCP –U 

MeForPrimeMinister@recipebook -PGubbins –Srecipes.database.windows.net -N -E



How It Works

Should you prefer (or need) to load data the good old-fashioned way, you can use BCP to do it. You must use

SQL Server authentication. It is essential to add @ServerName to the username in the BCP string. Of course, you

can use your own user/server/password. As I wish to override the IDENTITY setting of the destination table, I am

using the –E parameter here.



Hints, Tips, and Traps





All other BCP elements are those described in Recipe 5-4.







You must use the fully qualified DNS name as it is given in the Azure Management Portal

as the server name.



5-17. Loading Ad Hoc Data into SQL Server Azure

Problem

You want a quick and user-friendly way to load ad hoc data into SQL Server Azure.



Solution

Use the Import/Export Wizard that can connect to SQL Server Azure, and load the data. This is easy to do.

1.



Launch the Import/Export Wizard. Define your source database (SQL Server or

other). Click Next to move the Choose a Destination page.



2.



Select .Net Framework Data Provider for SQL Server.



3.



Specify the following:



277

www.it-ebooks.info



Chapter 5 ■ SQL Server Sources



Parameter



Element



Data Source:



recipes.database.windows.net (your Azure Server)



UserID:



MeForPrimeMinister (your Azure user)



Password:



Gubbins (your Azure password)



Initial Catalog:



CarSales (your Azure database)



Trust Server Certificate:



True



Encrypt:



True



The dialog box should look something like Figure 5-11.



Figure 5-11.  SQL Azure and the Import/Export Wizard

4.



Continue as you would for any other SSIS load operation.



278

www.it-ebooks.info



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

5-15. Loading Data into SQL Server Azure as Part of a Regular ETL Process

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

×