Setting the environment variables

What they're for

You can use environment variables to

This section covers the first two items. For information about environment variables that control logging, see Logging

SYBASE

The environment variable SYBASE points to the FreeTDS run-time directory. That convention originated with SYBASE, and many programs still rely on the SYBASE to discover the location of the "SYBASE" libraries.

The primary use of SYBASE is to advertise the location of the FreeTDS libraries. A secondary use is to point to the location of the interfaces file (if used, see the Appendix).

TDSVER

The environment variable TDSVER governs the version of the TDS protocol used to connect to your server. For a given server, FreeTDS inspects four sources in the following order to determine which TDS protocol version to use.

  1. The value specified in the TDSVER environment variable

  2. A freetds.conf file entry (see below)

  3. The interfaces file entry (see below)

  4. The --with-tdsver option passed to configure

FREETDSCONF

The FREETDSCONF environment variable may be used to specify the name and location of the freetds.conf file.

TDSPORT

The TDSPORT environment variable specifies a TCP port number to be used to connect to the dataserver with. It overrides the version default port (1433 for TDS 4.2/7.0/8.0, 4000 for TDS 5.0) as well as any port specified in the freetds.conf file.

TDSQUERY and DSQUERY

The TDSQUERY environment variable provides a server name to connect to if none is specified by the application. DSQUERY is the historical Sybase name for this variable.

TDSHOST

The TDSHOST environment variable overrides the host specified in the freetds.conf.

Setting environment variables

Of course, each shell is a little different. In the Bourne shell and variants such as ksh and bash, to set Sybase and TDSVER do:

$ export SYBASE=/usr/local/freetds  # (or your favorite directory)
$ export TDSVER=4.2

In csh:

$ setenv SYBASE /usr/local/freetds
$ setenv TDSVER 4.2

Checking your work

When you're done, you should see something very like this:

$ ls $SYBASE
etc include interfaces lib