3

Need to access the SQL server data from pgAdmin. I have tried with foreign data wrapper, but it's not working. I'm trying to access the data from " dbo.example " which is in SQL server from pgAdmin. Please provide the prerequisites to achieve this.

Sample Code:

CREATE EXTENSION postgres_fdw;

CREATE SERVER mssql_pm_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '121.112.141.88', port '1874');

CREATE USER MAPPING FOR postgres
SERVER mssql_pm_server
OPTIONS ( user '1122', password '1122',dbname 'db_Product');    

CREATE FOREIGN TABLE mssql_pm_table1(
    BusinessEntityID int NOT NULL,
    TerritoryID text
)
SERVER mssql_pm_server 
OPTIONS (table_name  'dbo.example');

Error:

ERROR: could not connect to server "mssql_pm_server"

DETAIL: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

SQL state: 08001

1 Answer 1

3

You need the proper foreign data wrapper to access Microsoft SQL server. The PostgreSQL foreign data wrapper is to connect to PostgreSQL databases.

You should use tds_fdw.

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

6 Comments

could you please elaborate on this..bcz i'm new to this and not able access the link too.
Every type of data source needs a specific foreign data wrapper. To access the link, you must get an internet connection.
please tell me how add this extension ERROR: could not open extension control file "C:/Program Files/PostgreSQL/10/share/extension/tds_fdw.control": No such file or directory SQL state: 58P01
You did not install the foreign data wrapper. You have to compile and install it.
i have downloaded the tds_fdw file,but i dont know how to install this..could you please help me to do
|

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.