Book Image

Microsoft SQL Server 2012 Integration Services: An Expert Cookbook

Book Image

Microsoft SQL Server 2012 Integration Services: An Expert Cookbook

Overview of this book

SQL Server Integration Services (SSIS) is a leading tool in the data warehouse industry - used for performing extraction, transformation, and load operations. This book is aligned with the most common methodology associated with SSIS known as Extract Transform and Load (ETL); ETL is responsible for the extraction of data from several sources, their cleansing, customization, and loading into a central repository normally called Data Warehouse or Data Mart.Microsoft SQL Server 2012 Integration Services: An Expert Cookbook covers all the aspects of SSIS 2012 with lots of real-world scenarios to help readers understand usages of SSIS in every environment. Written by two SQL Server MVPs who have in-depth knowledge of SSIS having worked with it for many years.This book starts by creating simple data transfer packages with wizards and illustrates how to create more complex data transfer packages, troubleshoot packages, make robust SSIS packages, and how to boost the performance of data consolidation with SSIS. It then covers data flow transformations and advanced transformations for data cleansing, fuzzy and term extraction in detail. The book then dives deep into making a dynamic package with the help of expressions and variables, and performance tuning and consideration.
Table of Contents (23 chapters)
Microsoft SQL Server 2012 Integration Services: An Expert Cookbook
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the first SSIS Package


After understanding the SSDT environment, you will be able to make your first SSIS Package. Depending on the Data Integration project's complexity, it's always recommended to think carefully while selecting tasks and components to apply, as well as the order in which to execute them.

In this recipe, the first package created will read the number of records in an Adventure Works Microsoft Sample table and store it inside the SSIS Package.

Getting ready

You can reuse the recipe created in the previous section (adding a new package to it), or start from scratch as explained in the following steps:

  1. Open SQL Server Data Tools (SSDT).

  2. Click on New Project… and a Windows dialog will appear.

  3. Click on the Business Intelligence Projects tab and under the Installed Templates section, select Integration Services Project.

  4. Provide a name and location for the SSIS project and an empty structure as well as a package will be created.

  5. In the Solution Explorer, select the empty package.dtsx and rename it to: P01_FirstSSISPackage.dtsx.

How to do it...

Now that the SSIS project is created, ensure that the empty package created by default is open and follow these steps:

  1. Create an OLEDB Connection to the Adventure Works Microsoft sample database at the package level. (As already mentioned, if you create this connection in the Solution Explorer window, the connection will be created at the project level and will be automatically included inside all the existent packages).

  2. In the Configure OLE DB Connection Manager Editor, select New... to create a new connection. If the connection already exists in the Data Connections list then select it here.

    Tip

    Ensure that the Control Flow tab is selected in the Package Designer area.

  3. Drag-and-drop Execute SQL Task from SSIS Toolbox and place into the control flow design surface.

  4. Double-click to edit Execute SQL Task or right-click and click on the Edit option.

  5. Set the Connection property of the task to the connection created in step two.

  6. Set the Result set to Single row.

  7. Add the SQL Statement: SELECT COUNT(*) AS NR_ROWS FROM SalesLT.Customer to get the number of records from the Customer table.

  8. Drag-and-drop Script Task from SSIS Toolbox and place into the Package Designer area and edit it by double-clicking on it.

  9. Create a new variable to store the value provided by the previous task and add a message box inside the script (the script task is explained more clearly in Chapter 11, Event Handling and Logging) as follows:

    MsgBox (Dts.Variables(0).Value, MsgBoxStyle.Information)
  10. Run the package by pressing F5.

How it works...

This recipe created a basic SSIS Package that included the most used tasks among SSIS projects: the Execute SQL Task, to communicate with a database through SQL queries and the Script Task that allows us to create some custom "work" when other tasks fall short. Naturally, it is too early to go into details with these two tasks, but this way it's possible to have an initial look at these common tasks.