Skip to content
Advertisement

Migrate data from SQL Server to PostgreSQL

I have a stored procedure function as well as table in the SQL Server enterprise 2014. I also have data in the table. Now I need same table and data in PostgreSql(pgAdmin4).

Can anyone suggest to me the idea to migrate data to POSTGRESQL or any idea on creating the SQL script so that I can use psql to run the script?

Advertisement

Answer

Depending on how much data you have, you could script out the table and data. Then you could tweak the script as needed for PostgreSQL:

  1. Right click on the SQL database > Tasks > Generate Scripts
  2. On the “Choose Objects” screen, select your specific table then select “Next>”
  3. On the “Set Scripting Options” screen, select “Advanced”
  4. Find the option called “Types of data to script”, then select “Schema and data” and select “OK”
  5. Set the filename and continue through the dialog until the file is generated
  6. Tweak the sql script for any specific PostgreSQL syntax

If there is a larger amount of data, you might look into some type of data transfer tool like SSIS.

Advertisement