tds-fdw / tds_fdw

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

ERROR: DB-Library error: DB #: 103, DB Msg: General SQL Server error: Check messages from the SQL Server, OS #: -1, OS Msg: , Level: 15 #124

Open laiwei1986 opened 7 years ago

laiwei1986 commented 7 years ago

Hi! I use Sybase and get the following error ERROR: DB-Library error: DB #: 103, DB Msg: General SQL Server error: Check messages from the SQL Server, OS #: -1, OS Msg: , Level: 15. I found that this is because the table name is longer than 30 characters. I would like to use "import schema" to solve the problem, but the problem remains.

Thank for help !

postgres=# CREATE SERVER server1
FOREIGN DATA WRAPPER tds_fdw
OPTIONS (servername '192.168.120.130',database 'arith',character_set 'SQL_ASCII', port '5100');
CREATE SERVER

postgres=# CREATE USER MAPPING FOR postgres
postgres-# SERVER server1
postgres-# OPTIONS (username 'sa', password '123456');
CREATE USER MAPPING

postgres=# IMPORT FOREIGN SCHEMA dbo
postgres-# EXCEPT (mssql_table)
postgres-# FROM SERVER server1
postgres-# INTO arith1
postgres-# OPTIONS (import_default 'true');
IMPORT FOREIGN SCHEMA

postgres=# select * from arith1.
arith1.bb123                                 arith1.opq123                                arith1.test_lw123
arith1.cancel_temp101                        arith1.pbcatcol                              arith1.test_pp
arith1.cc123                                 arith1.pbcatedt                              arith1.vv123
arith1.hhjj                                  arith1.pbcatfmt                              arith1.xx123
arith1.jl1                                   arith1.pbcattbl                              
arith1.kkk12                                 arith1.pbcatvld                              
arith1.kkkp                                  arith1.rs_lastcommit                         
arith1.laiwei19861234567890                  arith1.rs_threads                            
arith1.laiwei198612345678901234567890123456  arith1.testhh                                
postgres=# select * from arith1.laiwei198612345678901234567890123456;
ERROR:  DB-Library error: DB #: 103, DB Msg: General SQL Server error: Check messages from the SQL Server, OS #: -1, OS Msg: , Level: 15
onemojofilter commented 7 years ago

I have the same issue running Postgres 9.4.

Any word on how to resolve this?

laiwei1986 commented 7 years ago

You must add "tds_version '5.0'" in your "CREATE SERVER" Like this

CREATE SERVER mig_server
FOREIGN DATA WRAPPER tds_fdw
OPTIONS (servername '192.168.120.130',tds_version '5.0', port '5100');

If you do not add "tds_version '5.0'", The system default "tds_version '4.2'". 4.2 version of the agreement does not allow the string length of more than 30 characters.

onemojofilter commented 7 years ago

Thanks! I'll give it a shot.

rdnkrkmz commented 6 years ago

I managed to retrieve data from SQL Server. SQL Server Version: Microsoft SQL Server 2014 (SP2-GDR) - 12.0.5207.0 (X64) PostgreSQL Version: 9.4.6 (I compiled from source code on CentOS 6.9 x64) What I tried:

I tried 9.4.6 because someone said "I succeed with 9.4 but failed in after upgrade to 9.6" in these comment.

Hope this helps.