SQL Server Integration Services Tutorial

Problem

Microsoft SQL Server Integration Services (SSIS) is a very important Extract, Transform, and Load (ETL) tool widely used in corporate data management, data warehousing, data migrations and business intelligence. This ETL tool provides a powerful platform for coordinating and data workflow automation, including operational tasks, such as logging and scheduling, fault-tolerant error handling, support for big data sets scaling, and user-friendliness through its intuitive graphical interface. Built specifically for corporate data pipelines and analytics apps, SSIS gives data scientists the power to create, run, and monitor complicated processes of integrating information into one high-performance chain effectively.

Solution

The goal of this tutorial is to enable ETL developers to obtain practical knowledge to use SSIS in transforming and combining data through hands-on exploration to be ready for real-world challenges in managing information.

We’ll examine and discuss some of the most essential components and functionalities. We will begin by reviewing the Microsoft SSIS user interface and ways to navigate it. We will then address connection managers and set up connections to various data sources. Also, we will explore what makes control flow tasks different from data flow tasks and how they fit into data workflows.

In this demonstration, we’ll import an Excel \ CSV file into SQL Server, including derived column creation, conditional splitting, and the need for data conversion. Immediately after, we’ll look at variables and expressions in SSIS for dynamic data processing. Additionally, we will have another demonstration where multiple Excel \ CSV files are looped over until they reach the Microsoft SQL Server database to show how well it handles iterative copies of data via SSIS.

Creating an SSIS Project

First, we must create a new “Integration Services Project” using Visual Studio. Make sure you have already installed the SSIS extension from Visual Studio Market Place:

Create an SSIS Project

Next, we will configure the project name and directory.

Configure Your Project

SSIS Development Interface

The integration services development interface will appear once the SSIS project is created using Visual Studio. As shown in the screenshot below, it is mainly composed of four areas:

  1. SSIS Toolbox
  2. Package Designer (five tabs)
    1. Control Flow
    2. Data Flow
    3. Parameters
    4. Event Handlers
    5. Package Explorer
  3. Connection Managers
  4. Properties

More tools and options are available. However, they are outside the scope of this beginner-level tutorial.

SSIS development interface

Connection Managers

Since data is the main component of any data integration and analysis solution, the first thing to do in the ETL package is to define all data connections using connection managers. SSIS supports a wide variety of connection managers. For this tutorial, we will use an OLE DB connection to connect to an SQL Server database and a Flat File connection to connect to CSV files.

New Flat File Connection

We will start by adding a Flat File connection to read from a source CSV file. Right-click in the connection managers panel and click “New Flat File Connection…”

Side Note: If you are interested in checking all available connection managers, click on the “New Connection” menu item to select from an extended list.

Connection manager

The Flat File connection manager editor will appear. Let’s first change the connection manager name to Source File.

flat file connection manager editor

Now, we need to specify the source file path by clicking on “Browse…” Once we select a file, SSIS tries to detect the file metadata: encoding, text qualifier, row delimiter, etc. Sometimes, we need to edit those values manually as SSIS may not detect them accurately. After selecting the file, a warning appears mentioning that “Columns are not defined…”

flat file connection manager editor

Click on the Columns tab to let the connection manager detect the existing columns tab based on the first rows in the flat file.

flat file connection manager editor

If these columns are not defined accurately or their data types need to be changed, they can be edited manually in the Advanced tab.

flat file connection manager editor

After defining the first data connection, click OK.

SQL Server Data Connection

Now, let’s define the SQL Server data connection. We need to create an OLE DB connection manager.

OLE DB connection

In the Connection Manager editor, specify the SQL Server instance, the authentication parameters, and the database name. Other configurations are available in the All tab.

connection manager

To rename the OLE DB connection manager, right-click on its icon in the connection manager area and click Rename.

rename source file

Adding Tasks from the SSIS Toolbox

After adding and configuring the connection managers, we need to design our package. SSIS supports a wide variety of tasks, which can be found in the SSIS toolbox along with a brief description of each task.

Execute SQL Task

Let’s begin by adding an “Execute SQL Task,” which executes SQL statements using a connection manager that points to a relational data source.

SSIS toolbox

Double-click on the Execute SQL Task icon or drag and drop it within the control flow area. Next, double-click on the Execute SQL Task component in the control flow to open the editor.

Execute SQL Task Editor

In the Execute SQL Task Editor, set the connection type to “OLE DB” since we are using an OLE DB connection manager. Then, select the connection manager we previously created.

Next, add our SQL statement in the “SQLStatement” property, as shown below.

CREATE TABLE [InternationalSales] (
   [ID] INT IDENTITY(1,1) PRIMARY KEY,
   [ProductID] INT,
   [Date] Date,
   [Zip] varchar(50),
   [Units] INT,
   [Revenue] NUMERIC(18,6),
   [Country] varchar(50),
   [SourceFileName] nvarchar(4000))
Enter SQL Query

Click OK.

Execute SQL Task Editor

Click OK to finish configuring the task.

Test the Execute SQL Task

Now, to test this task, right-click on it and click “Execute Task” to execute it separately.

A green icon appears on the upper-right corner of the task to show that it was executed successfully.

task executed successfully

More details about the task execution can be seen under the Progress tab that appears after executing the task.

Progress of the task

Now, click the Stop button to exit debug mode.

Stop debugging

We can rename the task by right-clicking on it and clicking the “Rename” menu item.

rename task

Also, a task can be disabled by clicking on the “Disable” menu item.

disable task

Failed Execute SQL Task

Let’s try to execute the SQL task for a second time. It fails, as shown below.

Failed task

To check the cause of the failure, you can navigate to the Progress bar and read the package log.

Progress bar to investigate cause of failure

Since the error message is long and truncated, right-click on the error line and click on “Copy Message Text.

Copy Message Text

Now, we can paste the error message into a new Notepad window to read the full error message.

Paste error message into Notepad

It looks like the task failed because the table was already created. To avoid this error, we can edit the SQL statement to handle this situation, i.e., create the table if it does not exist, and truncate it if it exists.

IF NOT EXISTS ( SELECT 1 FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'InternationalSales')
 CREATE TABLE [InternationalSales] (
    [ID] INT IDENTITY(1,1) PRIMARY KEY,
    [ProductID] INT,
    [Date] Date,
    [Zip] varchar(50),
    [Units] INT,
    [Revenue] NUMERIC(18,6),
    [Country] varchar(50),
    [SourceFileName] nvarchar(4000)
)
ELSE
 TRUNCATE TABLE [dbo].[InternationalSales]
Correction SQL statement

Working with Data Flows

Control Flow manages the workflow and execution order of tasks within an SSIS package. It supports executing command line operators, web services, XML tasks, file system operations, and more tasks. A data flow handles the extraction, transformation, and loading of data within an SSIS package. A package has only one control flow and can have multiple data flows.

For instance, we can create a destination table in the control flow and use a data flow to load the data into it.

Let’s add a “Data Flow Task” from the SSIS toolbox.

Add Data Flow Task

Click on the “Execute SQL Task” and drag the arrow into the new “Data Flow Task.”

Execute SQL task

This will make both tasks connected and execute sequentially. This connector is called a “Precedence Constraint.” We can configure it by double-clicking on the connector.

Precedence constraint editor

For example, let’s change the precedence constraint to completion. This will tell the package to execute the data flow task even if the precedent “Execute SQL Task” fails.

Precedence constraint editor

Connectors example with “completion” label.

Precedence constraint editor

Designing the Data Flow

After adding the data flow, double-click on the “Data Flow Task” component to navigate to the “Data Flow” area. Note that the SSIS toolbox changes at this level.

SSIS toolbox

To read data from the Flat File connection manager, we need to add a “Flat File Source” component and select the connection manager.

Flat File source editor

Then, click on the “Columns” tab to read and define the component metadata as well as configure the output columns; we can ignore some columns or assign others their aliases.

Flat File source editor

Moreover, we can add a column that contains the source file path. After closing the editor, right-click on the “Flat File Source” and click on “Show Advanced Editor…

Show Advanced Editor

Navigate to the “Component Properties” tab. Assign a name to the “FileNameColumnName” property. In this tutorial, we will name it “SourceFileName.”

Advanced Editor for Flat File Source

Now, when we recheck the input columns, we can see that a new column has been added.

Flat File Source Editor

Data Transformation

After reading the data from the flat file, we need to convert the columns’ data types from text to the appropriate types. The search bar located at the top can be used to search SSIS toolbox items. First, add a “Data Conversion” component.

SSIS toolbox

Now, let’s connect the “Flat File” component to it.

Connecting the flat file source to the data conversion component

Double-click to open the data conversion editor and check three columns:

  • ProductID (Output Alias: INT_ProductID, Type: DT_I4)
  • Units (Output Alias: INT_Units, Type: DT_I4)
  • Revenue (Output Alias: NUM_Revenue, Type: DT_NUMERIC, Precision: 18, Scale: 6)
Data Conversation Transformation Editor

Derived Column

Now, let’s add a “Derived Column” component to apply some expression to the data.

SSIS Toolbox: Derived Column

Let’s connect the output of the Data Conversion to the Derived Column component.

Connecting Data Conversion output to the Derived Column component

We need to add two derived columns transformation:

  1. Add a new column DT_DATE using the following expression: (DT_DBDATE)[Date]
  2. Replace the “SourceFileName” column with the following expression: RIGHT(SourceFileName,FINDSTRING(REVERSE(SourceFileName),”\\”,1) – 1)
Add Derived Column

Conditional Split

Now, let’s add a “Conditional Split” component to ignore all records having a date before “01 January 2020.”

SSIS Toolbox: Conditional Split

We need to connect the derived column output to the conditional split component input.

Connecting derived column output to conditional split component input

Double-click to open the conditional split editor. We need to define our filter condition: YEAR([DT_DATE]) < 2020.

Define the filter condition

We need to edit the output names. The filter we added will be named “Old records,” and the default output name will be changed to “New records” since it will output the records that do not match the filters defined in the conditional split component.

OLE DB Destination

Finally, let’s add an “OLE DB Destination” component to insert the data into the destination table.

SSIS Toolbox: OLE DB Destination

Once we connect the conditional split output to the OLE DB destination, a prompt will appear to select the component output that will be linked to the OLE DB destination component. In this case, select “New records.”

Input Output Selection

Note that after connecting the components, we can still use the other output, “Old records,” and link it to another component, if needed.

Can Use Old records

Double-click the OLE DB destination component to select the connection manager and destination table, as well as configure the data load options.

OLE DB Destination Editor

Next, configure the column mapping. Navigate to the “Mappings” tab and map the input columns to the SQL destination columns, as shown in the image below.

OLE DB Destination Editor

Adding Data Viewers

To monitor the data during the package execution, double-click on any data flow path (connectors) and enable the data viewer to select the columns to be monitored.

Data Viewer

After executing the package, a window appears showing the data. Click on the Play button to continue fetching the data or the Detach button to stop monitoring the data and continue the package execution.

Data Viewer
Package execution

After executing the package, check the “Progress” tab to read the package execution log.

Package execution log

Inserting Multiple Flat Files into the Same Table

Consider that we need to loop over several flat files stored within a directory with the same structure. Go back to the control flow and add a “ForEach Loop Container.” Move the data flow task into the container (as shown in the screenshot below) and connect the execute SQL task to the container instead of the data flow task.

Inserting Multiple Flat Files into the Same Table

Working with Variables and Expressions

Right-click in the control flow area and click on “Variables.”

Working with Variables and Expressions

SSIS variables store values that can be used and updated during the execution of an SSIS package, allowing for dynamic control and configuration of tasks and data flows. In the Variables windows, click on “Add variable.”

Add variable

Add a new string variable named SourceFilePath and set the default value to the “Australia.csv” file.

Add variable

Now, double-click on the ForEach Loop container. Change the Enumerator type to “Foreach File Enumerator.” Select the Source directory and change the Files filter to *.csv to only read the CSV files. Make sure that file names are retrieved in a fully qualified format (full path).

ssis

Next, go to the Variable Mappings tab and map the file name retrieved by each loop to the “SourceFilePath” variable we created previously. This allows the full path of each file to be read using this variable on each iteration.

Foreach Loop Editor

Now, we should configure the flat file connection manager to read the input files. Click on the “Source File” connection manager. In the Properties tab, click on the button in the Expressions property.

ssis

Add a new expression to the “ConnectionString” property as follows: @[User::SourceFilePath]

Property Expression Editor

This will make the flat file connection manager link to the file path stored within the SourceFilePath variable.

Let’s try to execute the package. Note that the data flow task is executed several times.

Package execution

After the package execution finishes, go to the Progress tab and note that several files were manipulated.

Package execution

Checking the Package Structure

To check how the SSIS package is structured, click on the “Package Explorer” tab to see the package tasks and components tree.

Package Explorer

Finally, we can run the following query from SSMS to check how many records were imported from each file into the destination table.

SELECT [SourceFileName], COUNT(*) as RecordCount
  FROM [Test].[dbo].[InternationalSales]
  GROUP BY [SourceFileName]

We can note that six files were mentioned in the table.

Results of query in SSMS

Frequently Asked Questions

Do I need Visual Studio to build SSIS packages?

Yes. SSIS packages are usually developed in Visual Studio with the Integration Services extension installed. Make sure the extension version matches the SQL Server version you plan to target. If you are working with newer versions this article may help: Develop SSIS Packages with SSIS 2025.

Do I need SQL Server installed on the same machine?

No. SQL Server can be installed locally or on another server. SSIS only needs the right connection information and permissions. For learning, I usually prefer a local or test SQL Server instance because it is safer and easier to reset.

Should I hardcode file paths in an SSIS package?

For a quick test it is fine. For a package that will be reused I would avoid that. File paths usually change between machines and environments. Variables and parameters make the package easier to move later.

What should I check when a flat file does not load correctly?

Start with the flat file connection manager. Check the delimiter, check the column names, and check the data types. Also, check whether the first row contains headers. Most flat file issues come from metadata that SSIS detected in a way you did not expect.

Should I clean the data before loading it into SQL Server?

It depends on the file and the target table. If the file has simple type issues, then SSIS transformations may be enough. If the data has many quality problems, then I would separate the loading step from the cleaning step. This makes the process easier to test and review. For related ideas see Techniques to Cleanse Bad Data in SQL Server.

What should I do with bad rows during a data load?

Do not ignore them. Redirect them to another table or file so they can be checked later. This is better than failing the whole load without knowing which rows caused the issue. A good follow-up is Error Handling in SSIS Data Flow Task Part 1.

Why does an SSIS package work in Visual Studio but fail later?

This usually comes down to environment differences. The package may use a local file path. It may also run under a different account. Permissions can be different too. I would check the connection managers and file paths first.

When should I use variables in SSIS?

In general, variables are used to store values to reuse within several tasks or components.

When should I use parameters instead of variables?

Use parameters when the value should be passed into the package from outside. This is useful when the same package runs in development and production with different settings.

How can I make an SSIS package easier to troubleshoot?

Use clear names for tasks and connection managers. Check the Progress tab when testing. Add logging when the package becomes more important. Do not wait until the package is already in production. For more on SSISDB reporting see Reporting with the SQL Server Integration Services Catalog.

How do I run an SSIS package on a schedule?

After the package is tested, you can deploy it and run it from SQL Server Agent. Do not schedule it before testing the package with realistic data. A step-by-step walkthrough is available in Deploy and Schedule SSIS Package Step by Step.

Why can an SSIS package become slow?

A package can become slow because of large files. It can also be slow because of conversions or bad data flow settings. Start by checking where the time is spent in the package execution steps. Then review the data flow design before changing too many settings. This tip is a good next step: SSIS Performance Tuning When Designing ETL Pipelines.

Should I deploy SSIS packages to the SSIS Catalog?

For real projects I would use the SSIS Catalog. This gives you a better way to manage projects and environments. It also helps with logging and execution history. For more details see SSIS Catalog Deployment to Support Dev QA and Production.

What should I check before moving an SSIS package to production?

Check the connections first. Then check file paths and permissions. Also, check package parameters and logging. Run the package with data that looks close to production data. Small differences between test data and real data can cause unexpected failures.

Next Steps

6 Comments

    • Here are the data files for this exercise
      https://www.dropbox.com/scl/fi/ovxs8osbhbixvxx7b1glk/counries.zip?rlkey=tzx1lan3ucgl4i8dzk4r2ebjy&st=4lgsvdeq&dl=0

  1. Thanks for this amazing blog! The hands-on approach made it easy to follow along and get a solid understanding of SSIS in such a short time. I appreciate the clear explanations and practical examples—really helpful for getting started

  2. Thanks for this awesome tutorial! The hands-on approach made it so much easier to grasp SSIS concepts in such a short time.

Leave a Reply

Your email address will not be published. Required fields are marked *