Postgresql linked sever in Sql server

Raju MP 1 Reputation point
2020-12-19T06:45:22.8+00:00

Connection status is success.

Query 1: select * from openquery(XYZ,'select * from People')

Status : Success

Query 2: select * from XYZ.NewDB.[public].People

status: FAiled.

Error :

OLE DB provider "MSDASQL" for linked server "XYZ" returned message "ERROR: cross-database references are not implemented: "NewDb.public.people";
Error while executing the query".
Msg 7306, Level 16, State 2, Line 1
Cannot open the table ""newDB"."public"."people"" from OLE DB provider "MSDASQL" for linked server "xyz".

Please help..

Thanks in Advance...

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,788 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 111.1K Reputation points MVP
    2020-12-19T10:57:32.553+00:00

    It appears to be a limitation with the ODBC driver you are using.

    Intellisoft has an OLE DB provider for Postgres, and using a linked server set up with this provider, I was able to query a table in my Postgres database in Azure using four-part notation.

    1 person found this answer helpful.
    0 comments No comments

  2. Cris Zhan-MSFT 6,626 Reputation points
    2020-12-21T07:31:45.64+00:00

    Hi @Raju MP ,

    It seems to be related to the driver you are using.

    Please refer to the following article, which introduces the use of a linked server to query Postgresql with a four-part naming.
    https://www.mssqltips.com/sqlservertip/3662/sql-server-and-postgresql-linked-server-configuration--part-2/

    0 comments No comments

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.