Date June 15th, 2016 Author Vitaly Agapov

We have no need of other worlds. We need mirrors. We don't know what to do with other worlds.

Stanisław Lem «Solaris»

So let's assume that we need a small keyhole to look into SQL Server database and query some data from it. Maybe we'd like to automate some reporting stuff or to make some web GUI with some information stored in MSSQL. And of course we don't want to deal with Windows.

Fortunately there is such a project as FreeTDS. It gives us a driver for using with ODBC engine. I will show how to configure it and how to retreive some data right from MSSQL.

Everything written below is true for the case of RHEL/CentOS 7.

Step 1. Install FreeTDS driver

Firstly we should install freetds package. It can be installed from EPEL repository and will get unixODBC by dependency.

yum install freetds

Step 2. Configure ODBC

ODBC (Open Database Connectivity) is a standard API for interacting with any DBMS independently of the operating systems or databases themselves. For further information on ODBC refer here: http://www.unixodbc.org/odbcinst.html.

Foremost we should define the driver in file /etc/odbcinst.ini. To do that add or edit such a section in this file: