Fork me on GitHub

Supported datatypes

Type Constant1 JavaScript Result set Parameter
Exact numerics
bit TYPES.Bit Boolean
tinyint TYPES.TinyInt Number
smallint TYPES.SmallInt Number
int TYPES.Int Number
bigint2 TYPES.BigInt String
numeric3 TYPES.Numeric Number
decimal3 TYPES.Decimal Number
smallmoney TYPES.SmallMoney Number
money TYPES.Money Number
Approximate numerics
float TYPES.Float Number
real TYPES.Real Number
Date and Time
smalldatetime TYPES.SmallDateTime Date
datetime TYPES.DateTime Date
datetime2 TYPES.DateTime2 Date
datetimeoffset TYPES.DateTimeOffset Date
time TYPES.Time Date
date TYPES.Date Date
Character Strings
char TYPES.Char String
varchar4 TYPES.VarChar String
text TYPES.Text String
Unicode Strings
nchar TYPES.NChar String
nvarchar4 TYPES.NVarChar String
ntext TYPES.NText String -
Binary Strings5
binary TYPES.Binary Buffer
varbinary TYPES.VarBinary Buffer
image TYPES.Image Buffer
Other Data Types
null TYPES.Null null 6
TVP TYPES.TVP Object -
UDT TYPES.UDT Buffer -
uniqueidentifier5 TYPES.UniqueIdentifier String
variant TYPES.Variant any -
xml TYPES.xml String -

Notes

1Constants

The TYPES value used in the constants column can be obtained like this.

var TYPES = require('tedious').TYPES

2BigInt

Values are returned as a string. This is because values can exceed 53 bits of significant data, which is greater than a Javascript Number type can represent as an integer.

3Numeric, Decimal

For input parameters, default precision is 18 and default scale is 0. Maximum supported precision is 19 atm.

4VarChar, NVarChar

varchar(max) and nvarchar(max) are also supported.

5UniqueIdentifier

Values are returned as a 16 byte hexadecimal string.

Note that the order of bytes is not the same as the character representation. See Using uniqueidentifier Data for an example of the different ordering of bytes.

6Null parameter value

The value for a parameter of any supported data type may be null.