Search code examples
sqlsql-serverpostgresqlodbclinked-server

How to link from Postgresql to SQL Server via ODBC?


I need to be able to query a SQL Server database from within Postgresql. The Postgres instance is running locally and the SQL server set up as an ODBC data source. How do I add this as a linked server? Is there a better approach?

Thanks


Solution

  • The two available options are:

    • DBI-Link; or
    • The ODBC-FDW (SQL/MED foreign data wrapper)

    DBI-link is more mature, and will work on Windows. The ODBC FDW is likely to be better once it's properly finished, but at this point it isn't, and AFAIK it is not available on Windows.

    See: