skip to main content
Part 2: The 32-Bit/64-Bit Drivers : The SQL Server Legacy Wire Protocol Driver : Data Types
  
Data Types
The following table shows how the Microsoft SQL Server data types are mapped to the standard ODBC data types. Unicode Support lists Microsoft SQL Server to Unicode data type mappings.
Table 42. Microsoft SQL Server Data Types
SQL Server
ODBC
binary
SQL_BINARY
bigint 1
SQL_BIGINT
bit
SQL_BIT
char
SQL_CHAR
date 2
SQL_TYPE_DATE
datetime
SQL_TYPE_TIMESTAMP
datetime23
SQL_TYPE_TIMESTAMP
datetimeoffset 4, 5
SQL_WVARCHAR
decimal
SQL_DECIMAL
decimal() identity
SQL_DECIMAL
float
SQL_FLOAT
image
SQL_LONGVARBINARY
int
SQL_INTEGER
int identity
SQL_INTEGER
money
SQL_DECIMAL
numeric
SQL_NUMERIC
numeric() identity
SQL_NUMERIC
real
SQL_REAL
smalldatetime
SQL_TYPE_TIMESTAMP
smallint
SQL_SMALLINT
smallint identity
SQL_SMALLINT
smallmoney
SQL_DECIMAL
text
SQL_LONGVARCHAR
time6, 7
SQL_TYPE_TIMESTAMP
timestamp
SQL_VARBINARY
tinyint
SQL_TINYINT
tinyint identity
SQL_TINYINT
uniqueidentifier
SQL_GUID
varbinary
SQL_VARBINARY
varbinary(max) 8
SQL_LONGVARBINARY
varchar
SQL_VARCHAR
varchar(max)9
SQL_LONGVARCHAR

1 Bigint supported on Windows driver only.

2 Supported only on Microsoft SQL Server 2008 and higher.

3 Supported only on Microsoft SQL Server 2008 and higher.

4 Supported only on Microsoft SQL Server 2008 and higher.

5 Datetimeoffset mapping changes based on the setting of the Fetch TSWTZ as Timestamp option.

6 Supported only on Microsoft SQL Server 2008 and higher.

7 Time mapping changes based on the setting of the Fetch TWFS as Time option.

8 Supported only on Microsoft SQL Server 2005 and higher.

9 Supported only on Microsoft SQL Server 2005 and higher.

See Retrieving Data Type Information for information about retrieving data types.