freeTDS not using its config

I spent a long time today debugging a similar problem. I had set “TDS version” in freetds.conf but it was not being used in my ODBC connection. After reading the freetds source code (connectparams.c:odbc_parse_connect_string) I discovered that:

  • If your connection string uses “SERVER=” then both freetds.conf and odbc.ini are ignored
  • If your connection string uses “SERVERNAME=” then the settings in the appropriate freetds.conf server are used
  • If your connection string uses “DSN=” then the settings in the appropriate odbc.ini DSN are used

odbcinst.ini is a red herring. FreeTDS never checks that for settings.

The settings you specify in the connection string are always respected. It also always respects the environment variables like TDSVER.

Leave a Comment