Accessing a Microsoft SQL Server 2005 Server from Ubuntu 8.10 via ODBC / FreeTDS

Update: Check the encoding conversion note for FreeTDS

Following this post I’m detailing the process I’ve done (took me less than 10 minutes):

Set up variables on ~/.bashrc – no se si quedaron bien, las hice como root

 export ODBCINI=/etc/odbc.ini
 export ODBCSYSINI=/etc
 export FREETDSCONF=/etc/freetds/freetds.conf

All of the following can be installed via apt-get:

install unixodbc
install tdsodbc
install unixodbc-dev
install freetds-dev

configure /etc/freetds/freetds.conf (check the client charset section since FreeTDS uses ISO-8859-1 by default and it’s very likely you want to change it (check here ):

[MY_SERVER_NAME]
    host = 192.168.0.YY
    port = 1433
    tds version = 8.0 #Checar si se usan otras versiones: www.freetds.org
    client charset = UTF-8

install sqsh
test with

sqsh -S DB -U user -P pass

configure /etc/odbc.ini

[MY-SERVER-NAME]
Driver        = FreeTDS
Description     = Conexion a Sql  con FreeTDS / ODBC
Trace         = No
Servername    = MY-SERVER-NAME
Database    = MY-DATABASE-NAME

configurar /etc/odbcinst.ini

[MY-SERVER-NAME]
Driver        = FreeTDS
Description     = Conexion a Sql  con FreeTDS / ODBC
Trace         = No
Servername    = MY-SERVER-NAME
Database    = MY-DATABASE-NAME

test

isql DB SA PASS