Export PostgreSQL Table Data to SQL Server in SSIS

ssis-PostgreSql-SourceZappySys provides high performance drag and drop connectors for PostgreSQL Integration. In this post you will see how to Export PostgreSQL Table Data to SQL Server Table using SSIS PostgreSQL Source. PostgreSQL Source supports SQL language to query PostgreSQL data. PostgreSQL is a powerful, open source relational database with strong reputation for reliability, feature robustness, and performance.

In nutshell, this post will focus on how to read PostgreSQL Table Data and write into SQL Server table in few clicks.

Prerequisite

  1. First, you will need to have SSIS installed
  2. Secondly, make sure to have SSDT
  3. Thirdly, You have obtained PostgreSQL Credential.
  4. Finally, do not forget to install ZappySys SSIS PowerPack

Components Mentioned in this article

What is PostgreSQL?

PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. The origins of PostgreSQL date back to 1986 as part of the POSTGRES project at the University of California at Berkeley and has more than 30 years of active development on the core platform.

PostgreSQL has earned a strong reputation for its proven architecture, reliability, data integrity, robust feature set, extensibility, and the dedication of the open source community behind the software to consistently deliver performant and innovative solutions. PostgreSQL runs on all major operating systems, has been ACID-compliant since 2001, and has powerful add-ons such as the popular PostGIS geospatial database extender. It is no surprise that PostgreSQL has become the open source relational database of choice for many people and organisations.

Getting started with using PostgreSQL has never been easier – pick a project you want to build, and let PostgreSQL safely and robustly store your data.

Download and Install PostgreSQL

Please go to below download link and download the Windows version Binary package and install it and follow the steps from the installer.

https://www.postgresql.org/download/

ssis-PostgreSql-download

PostgreSQL Download

Create PostgreSQL Database and Table

  1. To do this, we will first open the pgAdmin Panel.
    ssis-PostgreSql-open-pgadmin

    Open PostgreSQL pgAdmin Panel

  2. It will open the pgAdmin Panel in the browser. Select Server and Right click on Databases to create database.
    PostgreSql Select Create Database

    PostgreSQL Select Create Database

  3. Enter the Database name and click on Save to create it.
    ssis-PostgreSql-create-database

    Create PostgreSQL Database

  4. Now select the created database under it expand Schemas and right click on Tables and click on create Table.
    ssis-PostgreSQL-select-create-table

    PostgreSQL Select Create Table

  5. Now enter the table name and go to columns tab.
    ssis-PostgreSQL-add-table-name

    PostgreSQL Enter Table Name

  6. Add the columns by clicking add button and give the desire column name and select the datatype for the same.
    ssis-PostgreSQL-add-table-columns

    PostgreSQL Add Table Columns

  7. Now, let’s insert some data using Query Editor.
    ssis-PostgreSQL-insert-data-in-table

    PostgreSQL Insert Data in Table

  8. That’s it, now let’s move forward to read the data from this table using SSIS PostgreSQL Source in the next the section.
    ssis-PostgreSQL-select-query-data

    PostgreSQL Select Query Data

Getting Started

In order to start, we will show several examples. ZappySys includes an SSIS PostgreSQL Source that will help you extract large amount of data from a PostgreSQL Database. PostgreSQL Source supports Multiple modes (i.e. Table or Query) to read data from PostgreSQL Database and many more operations. Here we are showing you is, How to read data from PostgreSQL collection.

You can connect to your PostgreSQL database by entering your PostgreSQL credentials.

Configure PostgreSQL Source to read data from the table

Let´s start with an example. In this SSIS PostgreSQL Source Task example, we will load the PostgreSQL table data to SQL Server.

  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

    Drag and Drop : Data Flow Task from SSIS Toolbox

  2. Drag and Drop PostgreSQL Source Task from the SSIS Toolbox and double click on it to edit it.
    ssis-drag-drop-PostgreSQL-source

    PostgreSQL Source

  3. Let’s create a connection for PostgreSQL Database.
    ssis-PostgreSQL-create-connection

    Create PostgreSQL Database Connection

  4. Let’s select the Table mode and select the table and click on preview.
    ssis-PostgreSQL-preview-table

    PostgreSQL Table Preview

  5. You can also use the query mode to filter the data and do more operation using query. You can find our several Examples also by clicking on <<View Examples>>.
    ssis-PostgreSQL-preview-query

    PostgreSQL Query Preview

  6. That’s it we are ready to load PostgreSQL Table data to SQL Server.

Load PostgreSQL Table 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 data from PostgreSQL in SSIS. We used SSIS PostgreSQL Source to read the data from PostgreSQL Table and load data into SQL Server Table. 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 PostgreSql Connection, SSIS PostgreSQL Source and tagged , , , .