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

Now let's look at how to load data into target like SQL Server, Oracle or Flat File. In below example we will see loading data into SQL Server database but steps may remain same for other targets which can be accessed using OLEDB Drivers (e.g. Oracle).
  1. Inside Data Flow, Drag and drop Upsert Destination Component from SSIS Toolbox
  2. Connect our Source component to Upsert Destination
  3. Double click Upsert Destination to configure it
  4. Select Target Connection or click NEW to create new connectionConfigure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS
  5. Select Target Table or click NEW to create new table based on source columns
  6. Click on Mappings Tab to Auto map columns by name. You can change mappings as you need SSIS Upsert Destination - Columns Mappings SSIS Upsert Destination - Columns Mappings
  7. Click OK to Save Upsert Destination Settings
  8. That's it, You are now ready to run data flow. NOTE: If you wish to debug data flow and see records when you run, add data viewer by right click on blue arrow > Click Enable Data Viewer
  9. To execute data flow, Right click anywhere inside Data Flow Surface and click Execute Task
 

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 , , , .