Stefan Hornburg (Racke)

FreeTDS

Perl DBI and Microsoft SQL Server

    Testing setup with tsql

    TDS version

    Date format

    Switch from ODBC with Microsoft driver to FreeTDS

Testing setup with tsql

Discover SQL server instances for server running on IP 10.10.6.6:

tsql -H 10.10.6.6 -L

TDS version

Selecting the correct TDS version can be the key to success in connecting to Microsoft SQL server.

For example with Microsoft SQL server version 10.50 and TDS version 7:

Error 20017 (severity 9):
    Unexpected EOF from the server
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

With TDS version 8 it connected just fine.

Date format

For further processing ISO dates are helpful and automatically provided by MySQL and PostgreSQL.

If you get dates in a format like "Feb 28 2007 12:00AM", you change the format in /etc/freetds/locales.conf like that:

[default]
    date format = %Y-%m-%d %H:%M:%S

Switch from ODBC with Microsoft driver to FreeTDS

In this case you might see the following warning:

Setting of CS_OPT_TEXTSIZE failed.

Reference: https://metacpan.org/pod/DBD::Sybase#Using-DBD::Sybase-with-MS-SQL