The SQL Server driver maps SQL Server SQL datatypes to ODBC SQL data types. The following table lists SQL Server SQL datatypes and shows the ODBC SQL data types to which they are mapped.
SQL Server SQL datatype | ODBC SQL data type |
---|---|
binary | SQL_BINARY |
bit | SQL_BIT |
char character |
SQL_CHAR |
datetime | SQL_TIMESTAMP |
decimal (SQL Server 6.x) dec (SQL Server 6.x) |
SQL_DECIMAL |
float double precision, float(n) where n = 24 – 53 |
SQL_FLOAT |
image | SQL_LONGVARBINARY |
int integer |
SQL_INTEGER |
money | SQL_DECIMAL |
numeric (SQL Server 6.x) | SQL_NUMERIC |
real float(n) where n = 1 – 23 |
SQL_REAL |
smalldatetime | SQL_TIMESTAMP |
smallint | SQL_SMALLINT |
smallmoney | SQL_DECIMAL |
sysname | SQL_VARCHAR |
text | SQL_LONGVARCHAR |
timestamp* | SQL_BINARY (SQL Server 6.x) SQL_VARBINARY (SQL Server 4.2x) |
tinyint | SQL_TINYINT |
varbinary binary varying |
SQL_VARBINARY |
varchar character varying char varying |
SQL_VARCHAR |
* The timestamp datatype is converted to the SQL_VARBINARY or SQL_BINARY ODBC data type, because values in timestamp columns are not datetime datatypes but varbinary(8) or binary(8) data that indicates the sequence of SQL Server activity on the row. |
Note The ODBC SQL Server driver does not convert ODBC SQL data of types SQL_CHAR, SQL_VARCHAR, or SQL_LONGVARCHAR to C data of types SQL_C_DATE or SQL_C_TIME. All other conversions are supported for the ODBC SQL data types listed. For information on supported conversions, see Appendix D of the Microsoft ODBC SDK Programmer's Reference.