PHPKonf 2020 Online


Requirements for Win32 platforms.

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to \winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access through named pipes. Configuration of the client will require installation of all the tools.

This extension is not available anymore on Windows with PHP 5.3 or later.

SqlSrv, an alternative driver for MS SQL is available from Microsoft: »

Requirements for Unix/Linux platforms.

To use the MSSQL extension on Unix/Linux, you first need to build and install the FreeTDS library. Source code and installation instructions are available at the FreeTDS home page: »


On Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length is 30 characters. On platforms where FreeTDS is used (Linux), this is not a problem.


On Windows, if you're using MSSQL 2005 or greater you must copy the ntwdblib.dll into the directory where you have installed php and overwrite the one thats already in there. This is due to the version distributed is old and outdated. Alternatively you can use the », ODBC, PDO_DBLIB or PDO_ODBC extensions, to talk to MSSQL.

add a note add a note

User Contributed Notes 2 notes

mihabo at hotmail dot com
10 years ago
I have struggled a lot to make PHP connect to a MS SQL server from under a Linux (using FreeTDS).
I installed the latest FreeTDS and tried to use usual host:port to connect to a server.
Finally when I configured freetds.conf like that:

        host =
        port = 1433
        tds version = 7.0

and used mysrvalias instead of the, it worked!
gustavo dot beavis at gmail dot com
5 years ago
I had problems with freeTDS version 4.2, and I believe that versions prior to 7.0 have this limit of 30 characters per fields.

I solved the problem by changing to version 8.0
To Top