How to read excel file in SSIS – Load into SQL Server

Introduction

ssis-excel-file-source

In this post, we will learn How to read excel file in SSIS – Load into SQL Server.  We will use SSIS PowerPack to connect Excel file. This article also covers how to read Excel file in SSIS.

SSIS Excel File Source Connector (Advanced Excel Source) can be used to read Excel files without installing any Microsoft Office Driver. You can extract using Table mode or query mode (SQL Command).

In nutshell, this post will focus on how to Read Excel file and load data into SQL Server Table.

Prerequisite

  1. First, you will need to have SSIS installed
  2. Secondly, make sure to have SSDT
  3. Make sure that Microsoft Excel installed
  4. Finally, do not forget to install ZappySys SSIS PowerPack

Components Mentioned in this article

What is Excel File Source Connector

SSIS Excel File Source Connector (Advanced Excel Source) can be used to read the Excel file without installing any Microsoft Office Driver. You can extract using Table mode or query mode (SQL Command). Support for flexible metadata detection mode so you can get accurate datatypes

Getting Started

In order to start, we will show several examples of how to connect the excel file and read data from the excel worksheet. ZappySys includes an SSIS Excel File Source Connector that will help you in reading excel sheet data from Excel File. Here we are showing you is, How to Load Excel File data in SQL Server using SSIS Pack.

Getting Started – Read Excel File in SSIS

Let´s start with an example. Let’s use our SSIS Excel File Source Connector, we will read data from Microsoft Excel File.

  1. First of All, Drag and drop Data Flow Task from SSIS Toolbox and double click it to edit.Drag and Drop SSIS Data Flow Task from SSIS Toolbox
  2. Now add Excel Source from the SSIS Toolbox.
    Drag and Drop Excel Source

    Drag and Drop Excel Source

  3. Double Click on Excel Source for edit and select New Connection and click on New button.
    ssis-edit-excel-file-source

    Edit Excel Source

  4. Now select the excel file path in and test connection in opened excel connection manager window and click on OK.
    Select Excel File For Connection

    Select Excel File For Connection

  5. Let’s read the Excel Workbook data using table mode and select sheet to read data from that excel sheet.
    ssis-excel-file-source-access-mode-table

    Load Excel Sheet Data using Access mode as a Table

  6.  We can also read Excel Workbook using SQL Query mode and filter the data.
    Read from Excel File using SQL Query Mode

    Read from Excel File using SQL Query Mode

  7. You can do various other things also in the query mode, find our various example here to read Excel Workbook using SQL Query mode.
    Read from Excel File using SQL Query Mode Examples

    Read from Excel File using SQL Query Mode Examples

     

  8.  That’s it we are ready to load excel file data to SQL Server.

Load Excel File data into SQL Server

ZappySys SSIS PowerPack makes it easy to load data from various sources such as REST, SOAP, JSON, XML, CSV or from other source into SQL Server, or PostgreSQL, or Amazon Redshift, or other targets. The Upsert Destination component allows you to automatically insert new records and update existing ones based on key columns. Below are the detailed steps to configure it.

Step 1: Add Upsert Destination to Data Flow

  1. Drag and drop the Upsert Destination component from the SSIS Toolbox.
  2. Connect your source component (e.g., JSON / REST / Other Source) to the Upsert Destination.

SSIS - Data Flow - Drang and Drop Upsert Destination Component

Step 2: Configure Target Connection

  1. Double-click the Upsert Destination component to open the configuration window.
  2. Under Connection, select an existing target connection or click NEW to create a new connection.
    • Example: SQL Server, or PostgreSQL, or Amazon Redshift.

Step 3: Select or Create Target Table

  1. In the Target Table dropdown, select the table where you want to load data.
  2. Optionally, click NEW to create a new table based on the source columns.

Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS

Step 4: Map Columns

  1. Go to the Mappings tab.
  2. Click Auto Map to map source columns to target columns by name.
  3. Ensure you check the Primary key column(s) that will determine whether a record is inserted or updated.
  4. You can manually adjust the mappings if necessary.

SSIS Upsert Destination - Columns Mappings

Step 5: Save Settings

  • Click OK to save the Upsert Destination configuration.

Step 6: Optional: Add Logging or Analysis

  • You may add extra destination components to log the number of inserted vs. updated records for monitoring or auditing purposes.

Step 7: Execute the Package

  • Run your SSIS package and verify that the data is correctly inserted and updated in the target table.

SSIS Upsert Destination Execution

Conclusion

Above all, in this blog, we learned how to read excel file worksheet Data in Excel File using SSIS Pack. We used Excel File Source Connector to read the Excel file and load data into SQL Server. You can download SSIS PowerPack here to try many other scenarios not discussed in this blog along with 70+ other components.

References

Finally, you can use the following links for more information:

Posted in SSIS Excel Connection, SSIS Excel Source and tagged , , , .