Connect to MS SQL Server

xiaoxiao2021-03-01  3

Freetds is used to connect MS SQL Server in linux. and freetds depends on UnixODBC. In fedora, execute

yum -y freetds, freetds-devel

 and freetds, unixodbc and freetds-devel will be installed. freetds-devel provides the driver.

Then, configure freetds: (The configuration file is /etc/freetds.conf)

[MSServer] host= port=1433 tds version=7.0

 Configure unixodbc

/etc/odbcinst.ini [MSSQLServer ] Description=TDS Driver Driver=/usr/lib/ Setup=/usr/lib/ Trace=Yes TraceFile=/tmp/freetds.log FileUsage=1 /etc/odbc.ini [MSSQLServer] Driver = MSSQLServer Description = MS SQL Server Data Source Trace = Yes TraceFile = /tmp/mstext.log Servername = Database = durango_60 Port = 1433  Notice that Driver refers to odbcinst.ini and Servername is defined in freetds.conf.

At last, we can test by executing following commands:

isql MSSQLServer user password

 Driver may be in different directory in different version. Make sure the path in the configuration file is valid.