0

I am using OPENQUERY through an ODBC connection to insert records from SQL server to Postgres. But it's very slow - a few minutes for 10000 records.
Also, SQL Server Service crashes when amount of data gets too large.

Anybody knows a better way ?

David
  • 1,051
  • 5
  • 14
  • 28
  • Have you looked at this? [http://stackoverflow.com/questions/758945/whats-the-fastest-way-to-do-a-bulk-insert-into-postgres][1] [1]: http://stackoverflow.com/questions/758945/whats-the-fastest-way-to-do-a-bulk-insert-into-postgres – STLDev Jun 11 '13 at 22:47
  • Have a look here:http://wiki.postgresql.org/wiki/Microsoft_SQL_Server_to_PostgreSQL_Migration_by_Ian_Harding –  Jun 11 '13 at 22:56

2 Answers2

2

Export the data in CSV format using a db utility command.

Import the data using the postgres COPY command.

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • thanks.is there a way to output CSV from SQL server with column headers and encoded special chars ? – David Jun 15 '13 at 16:24
  • Try reading [the Export documentation](http://msdn.microsoft.com/en-us/library/ms140052.aspx) – Bohemian Jun 15 '13 at 20:43
0

The standard and the simplest way is to use SSIS built-in Import/Export feature. You can find the steps in another SO question/answer.

Ehsan Mirsaeedi
  • 6,924
  • 1
  • 41
  • 46