FreeTDS - tsql connects, isql fails
The issue was this line in odbc.ini
Servername = 192.168.163.1
It should have been SQLEXPRESS which I think points to the name of the server configured in freetds.conf
Using FreeTDS and UnixODBC. Able to connect but cannot execute any SQL commands from isql or RODBC
It took me a LONG time to properly configure unixODBC with TDS, but for what it's worth, this set of instructions was my saving grace and what finally allowed me to get it working:
http://www.unixodbc.org/doc/FreeTDS.html
Pay particular attention to the second that references this command:
odbcinst -i -s -f tds.datasource.template
It's where my biggest problem resided. What happened was I was doing this as root (which is fine), but if you read carefully it indicates that every user that uses the driver has to run this command to 'register' the connection for their userid. Once I ran the same command under each other user, everything worked fine (since my actual code doesn't run as root).
One other thought... a quick and easy test to see if the connection is actually working with TDS (even before you try the ODBC piece) is to run bcp and export a really small table.
Try something like this, just to rule out the TDS install being the issue.
freebcp <database>.dbo.<tablename> out $HOME/foo.out -c -t '|' \
-S <hostname>:<port> -U <userid> -P <password>
It's a shame Microsoft and Unix don't play nicer together.
Using freetds and unixODBC to run queries with accents (á,é,í,ó,ú) on SQL Server
After trying for a long while the solution I found was quite simple and worked with tsql
and isql
. On the data source file for unixODBC I needed to set TDS_Version=8.0
.
The file before:
[MSSQL]
Driver = FreeTDS
Server = XXX.XXX.XXX.XXX
Port = XXXX
Database = name
The new file:
[MSSQL]
Driver = FreeTDS
Server = XXX.XXX.XXX.XXX
Port = XXXX
TDS_Version = 8.0
Database = name
Related Topics
While Loop in SQL Server 2008 Iterating Through a Date-Range and Then Insert
How to Use Max() on a Subquery Result
Solution for Speeding Up a Slow Select Distinct Query in Postgres
Better Way to Write Large Sqls Inside Rails Models
Count of Unique Values in a Rolling Date Range for R
Transpose/Pivot Distinct Row Attribute as Column and Group Another Attribute
How to Use Time-Series with Sqlite, with Fast Time-Range Queries
How to Convert Result of an Select SQL Query into a New Table in Ms Access
Rake Task to Truncate All Tables in Rails 3
What Does "Where 1" Mean in Sql
How to Order by Column with Non-Null Values First in Sql
Query on a Time Range Ignoring The Date of Timestamps
Postgres: Select All Row with Count of a Field Greater Than 1
Oracle SQL: Understanding the Behavior of Sys_Guid() When Present in an Inline View
Insert and Update a Record Using Cursors in Oracle