SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Azure DWH part 4: How to import data to Azure DWH using SSIS

By Daniel Calbimonte,

Introduction

There are several ways to import data to Azure SQL Data Warehouse (ASDW). This time, we will use SQL Server Integration Services (SSIS). This is my favorite way to import data because it is very flexible and you can import from different formats like a txt file, csv file, Oracle Table, DB2, SQL Server, MySQL and many other sources.

Requirements

  1. An Azure Subscription.
  2. An Azure SQL Server and an Azure Data Warehouse Database already created (if you do not know how to create a Data Warehouse, go to our article "Azure Machine Learning - Your first experiment" and go to the Creating an Azure SQL Data Warehouse close to the getting started section.
  3. Visual Studio 2013 or later. In this example, we are using VS2015.
  4. SQL Server Data Tools with SSIS installed.

Get Started

We will export a local CSV file with countries. The file name is country.csv and you can download from the resources section at the bottom of this article. The format of the file is the following:

We will import the csv file to ASDW using the SQL Server Data Tools:

In the menu, go to File>New project and select Integration Services Project:

Drag and drop the Data Flow Task to the design pane:

Double click in Data Flow Task and you will go to the Data Flow pane. Drag and drop the Flat File Source and the ADO NET Destination tasks. We will use the Flat File to specify the CSV file path and the ADO NET Destination will be used to connect to ASDW:

Rename the tasks to a more descriptive names:

Double click the Flat File Source and press New to create a connection:

Specify a Connection name and press the Browse button to select the csv file path and name:

Select the country.csv file mentioned before. The Locale, code page and format options will be selected by default:

Press the Columns page to verify that the data is correct:

Join the 2 tasks:

We now need the ASDW connection information. To get the Azure SQL Server Name, go to the Azure Portal and select the > icon and then select SQL server. I am assuming the you already have an Azure SQL Server and an ASDW database (check the requirements, step 2 for more instructions if you do not have one):

Click sqlcentralserver1 and go to Properties. Copy the SERVER NAME:

If you press the Database icon, you will find the ASDW database. In this example, the name is sqlcentralwarehouse:

In ADO.NET Destination, click new to create a new Connection:

In the Connection Manager, select the .Net Providers\SqlClient Data Provider. In the Log on to the server, select Use SQL Server Authentication. Specify a User Name and a password. These credentials were specified when the Azure SQL Server was created (check the requirements, step 2 if you are lost here) and the database name can be found in the Azure Portal in the databases section explained before:

Press the new button to create a new Table to import the csv information in ASDW:

Modify the text. We will create a table named dim_countries an ID of type int (integer) and a country of type varchar(50):

Go to mappings page to map the columns from the CSV file to the ASDW table:

Start the package to import the data:

If everything is OK, a green check icon will be displayed (it failed with a connection problem the first time I tried, but the second time that I run it worked fine):

You can verify in Visual Studio or in SSDT. For more information about connection to ASDW, refer to our Get started with ASDW article:

After connecting to ASDW, right click the Database and select New Query:

Write a select query in the dim_countries table and run the query:

As you can see, the data was imported successfully in ASDW from the CSV file.

Conclusion

SSIS is a good alternative to import data from different data sources. However, if your internet connection is not good, you may have problems with big amounts of data. The tools is very simple when you do not need to process the information too much. There are other ways to import the data that we will explain in later chapters.

References

 

Resources:

country.csv
Total article views: 847 | Views in the last 30 days: 28
 
Related Articles
FORUM

Server Connection Timeout

Server Connection

FORUM

import data without creating table?

tryign to import records with over 1000 fields so i don't want to have to create the table first

BLOG

Learn Different Options for Importing Data Into SQL Server

Most of the time users need to import their data into SQL Server for its proper management. Select ...

FORUM

SQL server Data import

SQL server Data import

FORUM

SQL Server 2005 import error

SQL Server 2005 import error

 
Contribute