tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
381 stars 102 forks source link

unable to fetch data from mssql server using foreign data wrapper in windows (for postgres 12+ version) #257

Closed vishalsinghji closed 4 years ago

vishalsinghji commented 4 years ago

All the things are working properly for select statement it's showing error its showing error- 20002, DB Msg: Adaptive Server connection failed (127.0.0.1), OS #: 0, OS Msg: No error, Level: 9 SQL state: HV00N

juliogonzalez commented 4 years ago

Your bug report is too generic.

Please report at least:

vishalsinghji commented 4 years ago

I am sharing you the syntax which i have used. MSSQL(18), POSTGRES(12),

1.> create extension tds_fdw;

2> CREATE SERVER mssql_svr FOREIGN DATA WRAPPER tds_fdw OPTIONS (servername 'localhost', port '1433', database 'test' );

3.>CREATE USER MAPPING FOR postgres SERVER mssql_svr;

4.> CREATE FOREIGN TABLE employee (id integer, name varchar(50),role varchar(50),Address varchar(50)) SERVER mssql_svr OPTIONS (schema_name 'dbo', table_name 'employee');

All the above queries are executing fine but for simple select query it is not working.

5.> select * from employee;

ERROR: DB-Library error: DB #: 20002, DB Msg: Adaptive Server connection failed (localhost), OS #: 0, OS Msg: No error, Level: 9 SQL state: HV00N

GeoffMontee commented 4 years ago

Hi @vishalsinghji,

It looks like tds_fdw is failing to connect to the MS SQL Server instance. Are you sure that you provided the correct credentials to the user mapping? See here: https://github.com/tds-fdw/tds_fdw/blob/master/UserMappingCreation.md

vishalsinghji commented 4 years ago

@GeoffMontee thanks man i am able to resolve the issue . There was an error in user mapping .