This one is really starting to stump me. I'm running Ubuntu 12.04 and am trying to connect to a box running MS SQL server 2012. First I'll provide some information on my setup:
My freetds.conf:
[EXNAME]
host = IP
port = 1433
tds version = 7.0
client charset = UTF-8
After setting up my freetds.conf I first test my connection with tsql which produced the expected (and welcomed) prompt:
...
using default charset "UTF-8"
1>
So my FreeTDS setup appears to be working ok. Next I setup odbc.ini and obdcinst.ini:
odbc.ini:
[EXNAME]
Driver = FreeTDS
ServerName = EXNAME
UID = Me
PWD = Pass
odbcinst.ini:
[FreeTDS]
Description = FreeTDS Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
Following this setup I run osql to check. It outputs all the expected responses, it is able to find the drivers and the correct paragraphs in ondcb.ini for example:
[EXNAME] found in /etc/odbc.ini
found this section:
[EXNAME]
Driver = FreeTDS
ServerName = EXNAME
UID = Me
PWD = Pass
looking for driver for DSN [EXNAME] in /etc/odbc.ini
found driver line: " Driver = FreeTDS"
And so on until:
DSN [EXNAME] has servername "" (from /etc/odbc.ini)
osql does not seem to be detecting the servername in odbc.ini.
Following this check I am able to connect via isql but I cannot run any SQL commands. I receive the following error:
SQL> SELECT name FROM master..sysdatabases;
[37000][unixODBC][FreeTDS][SQL Server]Could not find stored procedure 'SELECT'.
[ISQL]ERROR: Could not SQLExecute
What I've tried:
A.) Just about every configuration and naming convention one could think of across freetds.conf and both .ini files. Post changes I perform the same tests above and arrive at the same result
B.) Reproducing the error outside of isql. ROBC given me exactly the same error. Of course, this is expected but I figured why not
C.) SQL variants besides MS SQL Server. I figured just in case someone was mis-informing me I tried some MySQL commands there as well. This could be a SQL problem but I'm ot sure.
D.) The closest I've come to finding a similar error (well result I guess) to what osql spit out is here. As suggested in the last post, the problem, at least in so far as it relates to osql's response might relate to awk
. As suggested I test awk
by making a variable and trying to parse out the servername:
$ SERVER_LINE='ServerName = SERVER'
$ echo ${SERVER_LINE} | awk -F '=[[:space:]]*' '{print $2}'
This should result in SERVER
but instead I get "".
That's all I have. In summary OSQL cannot seem to find the servername in odbc.ini and this may or may not result in me not being able to execute any commands from ISQL or ROBC. I'm beginning to suspect that these problems are disjoint but any help would be GREATLY appreciated.
EDIT:7/31/2014 Got this all working. There were some other issues going on in addition to what I highlighted. I ended up having to set up a similar connection on both a Mac and Linux box. Here are the instructions for both: http://www.joecjr.com/2014/07/27/install-and-use-freetds-unixodbc-and-rodbc-or-pyodbc/