views:

65

answers:

1

I need to migrate a database from Postgres 7 to SQL Server 2008. I am familiar with the SSIS Import and Export wizard but I am stumped about how to define the data source or define the data provider.

What is the best way to migrate Postgres to SQL Server, and how do I define data sources/drivers for postgres?

+3  A: 

I wish you the best of luck in trying to import from PostgreSQL into SQL Server using SQL Server Import and Export Wizard. However, I have read numerous message board threads with people having trouble getting it to work. For example:

Here is the most helpful thread that I have found on the topic:


To help someone who might be trying to achieve similar goal as mine. Instead of selecting the “PostgreSQL OLE DB Provider” in the data source drop down menu of SQL Server Import and Export Wizard, select “.Net Framework Data Provider for Odbc”

Then you have to make a DSN and provide a ConnectionString. Following ConnectionString worked for me

Driver={PostgreSQL};Server=localhost;Port=5432;Database=TestMasterMap;Uid=postgres;Pwd=;

To make a DSN you have to go into Administrative Toolsà Data Sources (ODBC) and create a user DSN. Once this is done you can supply the DSN name in the DSN text box of SQL Server Import and Export Wizard.


One commenter claimed that it worked, but that he got "Out of memory while reading tuples" errors on big tables. So for tables with more than 3 million rows, he had to break the import up into 3 million row chunks.

Also, there's a link to the native .NET provider for PostgreSQL in that thread.

Personally, if this is something that I only had to do once, and if I understood the schema and the data fairly well, I would try:

  1. export the data from PostgreSQL as flat files
  2. create the schema in SQL Server (without PKs or constraints)
  3. use the SSIS Import/Export Wizard to import the flat files
  4. then create PKs and necessary constraints

It might take you less time to do the above than messing with SSIS Import/Export Wizard and PostgreSQL for days (but if would be nice of those tools worked!)

JohnB