skip to main content
Supported data types : Microsoft SQL Server data types
 

Try DataDirect Cloud Now

Microsoft SQL Server data types

The following table shows how the Microsoft SQL Server and Windows Azure SQL Database data types are mapped to the standard data types for ODBC and JDBC.
Note: When the EnableWCharSupport connection parameter is set to true for the DataDirect Cloud Driver for ODBC, character types are mapped to the corresponding ODBC W-Types. For example, the varchar(max) type is mapped to the Unicode type SQL_WLONGVARCHAR.
Table 10. SQL Server data types
SQL Server data type
JDBC data type
ODBC data type
bigint
BIGINT
SQL_BIGINT(-5)
binary
BINARY
SQL_BINARY(-2)
bit
BIT
SQL_BIT (-7)
char
CHAR
SQL_CHAR(-8) or SQL_CHAR(1)
date
DATE
SQL_TYPE_DATE(91)
datetime
TIMESTAMP
SQL_TYPE_TIMESTAMP(93)
datetime2 1
TIMESTAMP
SQL_TYPE_TIMESTAMP(93)
datetimeoffset
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
decimal
DECIMAL
SQL_DECIMAL(3)
float
FLOAT
SQL_FLOAT(6)
int
INTEGER
SQL_INTEGER(4)
image
LONGVARBINARY
SQL_LONGVARBINARY(-4)
money
DECIMAL
SQL_DECIMAL(3)
nchar
CHAR
SQL_CHAR(-8) or SQL_CHAR(1)
ntext
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
numeric
NUMERIC
SQL_NUMERIC(2)
nvarchar
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
nvarchar(max)
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
real
REAL
SQL_REAL(7)
smalldatetime
TIMESTAMP
SQL_TYPE_TIMESTAMP(93)
smallint
SMALLINT
SQL_SMALLINT(5)
smallmoney
DECIMAL
SQL_DECIMAL(3)
sql_variant
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
sysname
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
text
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
time 2
TIMESTAMP
SQL_TYPE_TIMESTAMP(93)
timestamp
BINARY
SQL_BINARY(-2)
tinyint
TINYINT
SQL_TINYINT(-6)
uniqueidentifier
CHAR
SQL_CHAR(-8) or SQL_CHAR(1)
varbinary
VARBINARY
SQL_VARBINARY(-3)
varbinary(max)
LONGVARBINARY
SQL_LONGVARBINARY(-4)
varchar
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
varchar(max)
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
xml
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)

1 Supported only on Microsoft SQL Server 2008 and higher.

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