SQL types mapping: SQL Server
Original data types | Microsoft SQL Server data types |
---|---|
CHAR(n) |
CHAR(n) or NCHAR(n) (see
note 1) |
VARCHAR(n[,m]) |
VARCHAR(n) or NVARCHAR(n) (see
note 1) |
LVARCHAR(n) |
VARCHAR(n) or NVARCHAR(n) (see
note 1) |
NCHAR(n) |
NCHAR(n) (see note 1) |
NVARCHAR(n[,m]) |
NVARCHAR(n) (see note 1) |
BOOLEAN |
BIT |
SMALLINT |
SMALLINT |
INTEGER |
INTEGER |
BIGINT |
BIGINT |
INT8 |
BIGINT |
SERIAL[(start)] |
INTEGER (see note 2) |
BIGSERIAL[(start)] |
BIGINT (see note 2) |
SERIAL8[(start)] |
BIGINT (see note 2) |
DOUBLE PRECISION / FLOAT[(n)] |
FLOAT(n) |
REAL / SMALLFLOAT |
REAL |
DECIMAL(p,s) |
DECIMAL(p,s) |
DECIMAL(p) with p<=19 |
DECIMAL(2*p,p) |
DECIMAL(p) with p>19 |
N/A |
DECIMAL |
DECIMAL(32,16) |
MONEY(p,s) |
DECIMAL(p,s) |
MONEY(p) |
DECIMAL(p,2) |
MONEY |
DECIMAL(16,2) |
DATE |
DATE |
DATETIME HOUR TO MINUTE |
TIME(0) |
DATETIME HOUR TO SECOND |
TIME(0) |
DATETIME HOUR TO FRACTION(n) |
TIME(n) |
DATETIME YEAR TO MONTH |
DATETIME2(0) |
DATETIME YEAR TO DAY |
DATETIME2(0) |
DATETIME YEAR TO HOUR |
DATETIME2(0) |
DATETIME YEAR TO MINUTE |
DATETIME2(0) |
DATETIME YEAR TO SECOND |
DATETIME2(0) |
DATETIME YEAR TO FRACTION(n) |
DATETIME2(n) |
INTERVAL q1 TO q2 |
CHAR(50) |
TEXT |
VARCHAR(MAX) or NVARCHAR(MAX)
(see note 3) |
BYTE |
VARBINARY(MAX) |
Notes:
- For character type conversions, see CHAR and VARCHAR data types.
- For serial emulation, see SERIAL and BIGSERIAL data types.
- For TEXT type conversions, see TEXT and BYTE (LOB) types.