Gentoo Wiki


Microsoft SQL Server is a relational database management system (RDBMS) produced by Microsoft. This guide will demonstrate how to connect to MSSQL Server.


Required packages

In order to connect to the Microsoft SQL Server, the following need to be installed.

echo "dev-db/freetds mssql odbc" >> /etc/portage/package.use
emerge unixODBC freetds

Configure FreeTDS

FreeTDS is an open source implementation of the TDS (Tabular Data Stream) protocol, which is used by Microsoft SQL Server. Edit /etc/freetds.conf to include the following

    host = hostname.of.database.server
    port = 1433
    tds version = 4.2

Replace the port and tds version according to your implementation of SQL Server.

Test FreeTDS Configuration

# tsql -S DB_DEF_NAME -U username -P password

Set up the ODBC Database Connection and Driver

Open Database Connectivity (ODBC) provides a standard software API method for using database management systems (DBMS).
Edit /etc/unixODBC/odbc.ini

    Driver        = FreeTDS
    Description   = Description of this particular database connection
    Trace         = No
    Servername    = DB_DEF_NAME
    Database      = database_to_use

Now edit /etc/unixODBC/odbcinst.ini

    Description   = TDS drive (Sybase/MS SQL)
    Driver        = /usr/lib/
    Setup         = /usr/lib/
    SPTimeout     =
    CPReuse       =
    FileUsage     = 1

Test ODBC Configuration

# isql DB_DEF_NAME username password

You should see something like this if everything went correctly

| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |



Retrieved from ""

Last modified: Mon, 04 Aug 2008 09:41:00 +0000 Hits: 626