7

There are SQL Server 2008 R2 and PostgreSQL 9.2 under Windows (currently XP SP3). How can I query SQL Server from PostgreSQL? No problem when SQL Server->PostgreSQL via Linked Server.
Searching web I found odbc_fdw which is not possible to compile for 9.2.

Is there any working solution?

4
  • PostgreSQL dblink only connects PostgreSQL to PostgreSQL Commented Feb 2, 2013 at 23:15
  • @OMG Ponies: exactly, but dblink is not the issue... I am planning to use OLE DB or ODBC plus any available working fdw. Commented Feb 2, 2013 at 23:31
  • Best of luck. How current does the data need to be? Could it work as a nightly job to suck the data from SQL Server to populate a PostgreSQL database? Commented Feb 3, 2013 at 0:12
  • Thanks. Not nightly, should run as regular queries. Currently application layer is used (php script) which takes data from both dbs and operate with arrays outputting result to client. But because of big number of rows I need to iterate several times instead of doing everything in db in one query. To transfer data costs a lot ( Commented Feb 3, 2013 at 0:29

2 Answers 2

4

In addition to the standard but immature SQL/MED and foreign data wrappers mentioned by @vyegorov, the traditional solution to this problem has been DBI-Link, a set of foreign data mapping functions that use Perl DBI via plperl.

http://pgfoundry.org/projects/dbi-link/

Sign up to request clarification or add additional context in comments.

Comments

2

There is a SQL/MED extension that describes how database can access external data.

PostgreSQL supports this part of the standard via the Foreign Data Wrappers. The linked page describes all (well, almost all I suppose) FDWs that are available now. I think that your finding on odbc_fdw are correct, but I admit, that it is not always straightforward to make FDWs working, especially on Windows.

You can take a look at Multicorn if you're familiar with Python.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.