Default SQL Server Data Types


DownloadDownload PHP Driver

When sending data to the server, the Microsoft Drivers for PHP for SQL Server converts data from its PHP data type to a SQL Server data type if no SQL Server data type has been specified by the user. The table that follows lists the PHP data type (the data type being sent to the server) and the default SQL Server data type (the data type to which the data is converted). For details about how to specify data types when sending data to the server, see How to: Specify SQL Server Data Types When Using the SQLSRV Driver.

PHP Data TypeDefault SQL Server Type in the SQLSRV DriverDefault SQL Server Type in the PDO_SQLSRV Driver
NULLvarchar(1)not supported
Floatfloat(24)not supported
String (length less than 8000 bytes)varchar()varchar()
String (length greater than 8000 bytes)varchar(max)varchar(max)
ResourceNot supported.Not supported.
Stream (encoding: not binary)varchar(max)varchar(max)
Stream (encoding: binary)varbinaryvarbinary
ArrayNot supported.Not supported.
ObjectNot supported.Not supported.
DateTime (1)datetimeNot supported.

Constants (Microsoft Drivers for PHP for SQL Server)
Converting Data Types
PHP Types
Data Types (Transact-SQL)

Community Additions