How to talk to MS SQL server from Linux using freetds driver. See the appropriate .conf files for configuration
To test the tsql freetds driver and conf using tsql
:
~$ tsql -S mssql2 -U '<username>' -P '<password>'
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
If prompted with 1>
then the connection was successful. The name mssql2
after the -S
should exists in the /etc/freetds.conf
.
Once this is successful, make sure odbc
config works using isql
too. The test
after the -v
needs to match the settings from the /etc/odbc.ini
.
~$ isql -v test <username> <password>
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> SELECT TestTime FROM [testdb].[dbo].[metric1]
+------------------------+
| TestTime |
+------------------------+
| 2017-08-15 19:17:43.000|
| 2017-08-15 19:17:47.000|
| 2017-08-15 19:17:48.000|
| 2017-08-15 19:18:01.000|=
+------------------------+
SQLRowCount returns 46
46 rows fetched
SQL> quit