Fork me on GitHub

Supported datatypes

Type Constant1 JavaScript Result set Parameter
Exact numerics
bit TYPES.Bit Boolean ✓ ✓
tinyint TYPES.TinyInt Numeric ✓ ✓
smallint TYPES.SmallInt Numeric ✓ ✓
int TYPES.Int Numeric ✓ ✓
bigint2 TYPES.BigInt Numeric ✓ ✓
numeric TYPES.Numeric Numeric ✓ -
decimal TYPES.Decimal Numeric ✓ -
smallmoney TYPES.SmallMoney Numeric ✓ -
money TYPES.Money Numeric ✓ -
Approximate numerics
float TYPES.Float Numeric ✓ ✓
real TYPES.Real Numeric ✓ ✓
Date and Time
smalldatetime TYPES.SmallDateTime Date ✓ ✓
datetime TYPES.DateTime Date ✓ ✓
Character Strings
char TYPES.Char String ✓ -
varchar3 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 [Numeric] ✓ -
varbinary TYPES.VarBinary [Numeric] ✓ -
image TYPES.Image [Numeric] ✓ -
Other Data Types
null TYPES.Null null ✓ ✓7
uniqueidentifier6 TYPES.UniqueIdentifier [Numeric] ✓ ✓
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.

3,4VarChar, NVarChar

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

5Binary Strings

Values are represented as arrays of integer values.

6UniqueIdentifier

Values are returned as a 16 byte array of integer values.

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.

7Null parameter value

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