PHP and MSSQL with FreeTDS: SQL Server columns get truncated at 30 characters
Beware this content is over 4 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.
If you’re using PHP 5 and MSSQL extension to retrieve data from Microsoft SQL Server and you’re seeing your columns truncated at around the 30 character mark, it could be down to your FreeTDS settings.
For context, I’m using Ubuntu 14.04 (Trusty) and when I run the following command, I can see the following output:
$ tsql -C output
The quick and easy way to do this is simply to install the FreeTDS kitchen-sink which gives you access to further settings and generally better debugging support.
apt-get remove --purge freetds-common
Then restart PHP and your web server, which in my case is nginx.
service php5-fpm restart && service nginx restart
You may also have to explicitly define the TDS protocol version to use. Add TDS protocol version to:
Further helpful information here: