How import a Postgres .dump into a SQL Sever database.

Mark McCumber 431 Reputation points
2023-02-16T23:07:44.37+00:00

Hi All:

I want to import a postgres dump file(fec_fitem_sched_a.dump) into a  database in sql server. What are the steps for importation?

MRM256

SQL Server Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. LiHongMSFT-4306 31,566 Reputation points
    2023-02-17T02:54:53.2333333+00:00

    Hi @Mark McCumber

    Not an expert on SSIS, but you could try using SSIS export directly from Postgres to SQL Server.

    If not work, you could re-dump as CSV and try again. Refer to this article: Import Text and CSV Files into SQL Server Database with SSIS Script Task.

    Also, you could bulk import csv/txt into SQL Server using BCP.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-02-17T19:39:25.1166667+00:00

    it depends on the dump format. if the format is sql text, you will need to go thru the text file and fix any sql server syntax errors. once this is done, you could use sqlcmd to execute script.

    note: probably handy to add "go" statements. you may also want to break the dump text file into smaller files.


  3. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-02-18T16:41:11.9433333+00:00

    I read https://www.postgresql.org/docs/current/app-pgdump.html and I learnt that pg_dump can produce two different types of backup:

    Dumps can be output in script or archive file formats

    The suffix .dump seems to suggest that you have an archive file. Then again, as it says in a StackOverflow thread I looked at, that is just a name.

    You said that you looked that file in UltraEdit, and you saw some SQL commands, but it was in hex format. Did you try change the presentation to normal text file? If you see a nice SQL script, you have a script format, and you can run it on SQL Server, but as Bruce says, you may have to edit it, since syntax may not be the same.

    On the other hand, if you see random characters that you cannot make sense of, you presumably have the archive format.

    I can see two options:

    1. Find (or install) a Postgres server, load the archive file, take a script dump and load to SQL Server. (Or use an SISS package, if there is a Postgres connector.)
    2. When I googled, I found https://www.rudderstack.com/guides/how-to-load-data-from-postgresql-to-ms-sql-server/, which seems to suggest that they have a service or a product. I did come as far to see if this comes with a price tag.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.