Reputation: 31
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.
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: 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
Upvotes: 3
Views: 13503
Reputation: 247103
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.
Upvotes: 3