SQL Server Datatypes QuickRef

Datatypes

Datatypes
Familynamesince SQL#byteslower boundupper bound
Date/Timedate200830001-01-019999-12-31
datetime81753-01-01 00:00:00.0009999-12-31 23:59:59.997
datetime2[(p)]2008p < 3/5/8 = 6/7/80001-01-01 00:00:00.0…9999-12-31 23:59:59.9…
datetimeoffset2008100001-01-01 00:00:00.0000000 -14:009999-12-31 23:59:59.9999999 +14:00
smalldatetime41900-12-31 00:002079-12-31 23:59
time2008500:00:00.000000023:59:59.9999999
Integerbigint20008-9,223,372,036,854,775,8089,223,372,036,854,775,807
bit101
int4-2,147,483,6482,147,483,647
smallint2-32,76832,767
tinyint10255
Monetarymoney8-922,337,203,685,477.5808922,337,203,685,477.5807
smallmoney4-214,748.3648214,748.3647
Approximate Numericfloat[(n)]8
real4
Exact Numericdecimal[(p[,s])]p < 9/19/28/38 = 5/9/13/17
numeric[(p[,s])]
Binarybinary[(n)]n ≤ 8,000
varbinary[(n)]n ≤ 8,000
Characterchar[(n)]n ≤ 8,000
nchar[(n)]7n × 2 ≤ 8,000
nvarchar[(n)]7n × 2 ≤ 2,147,483,647
varchar[(n)]n ≤ 8,000
Long Text and Binaryimagedep. 2005
  • 16 byte in-row pointer to ≤ 2,147,483,647 bytes data.
  • Max types are stored in-row up to 8,000 bytes.
  • n(var)char/ntext are stored as UTF-16/DBCS, two bytes per character.
ntext7, dep. 2005
nvarchar(max)2005
textdep. 2005
varbinary(max)2005
varchar(max)2005
Specialhierarchyid2008A slash-separated path: /1/3/
rowversion8
sql_variant2000Stores any datatype except text, ntext, image, timestamp, and sql_variant (max 8016 bytes).
table2000Faster than temporary tables. declare @name table ( … table definition … )
uniqueidentifier716
xml200516 (in-row pointer)XML data with a schema is stored as a parsed tree.