Datatypes
Family | name | since SQL# | bytes | lower bound | upper bound |
Date/Time | date | 2008 | 3 | 0001-01-01 | 9999-12-31 |
datetime | | 8 | 1753-01-01 00:00:00.000 | 9999-12-31 23:59:59.997 |
datetime2[(p)] | 2008 | p < 3/5/8 = 6/7/8 | 0001-01-01 00:00:00.0… | 9999-12-31 23:59:59.9… |
datetimeoffset | 2008 | 10 | 0001-01-01 00:00:00.0000000 -14:00 | 9999-12-31 23:59:59.9999999 +14:00 |
smalldatetime | | 4 | 1900-12-31 00:00 | 2079-12-31 23:59 |
time | 2008 | 5 | 00:00:00.0000000 | 23:59:59.9999999 |
Integer | bigint | 2000 | 8 | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
bit | | 1 | 0 | 1 |
int | | 4 | -2,147,483,648 | 2,147,483,647 |
smallint | | 2 | -32,768 | 32,767 |
tinyint | | 1 | 0 | 255 |
Monetary | money | | 8 | -922,337,203,685,477.5808 | 922,337,203,685,477.5807 |
smallmoney | | 4 | -214,748.3648 | 214,748.3647 |
Approximate Numeric | float[(n)] | | 8 |
real | | 4 |
Exact Numeric | decimal[(p[,s])] | | p < 9/19/28/38 = 5/9/13/17 |
numeric[(p[,s])] | |
Binary | binary[(n)] | | n ≤ 8,000 |
varbinary[(n)] | | ≤ n ≤ 8,000 |
Character | char[(n)] | | n ≤ 8,000 |
nchar[(n)] | 7 | n × 2 ≤ 8,000 |
nvarchar[(n)] | 7 | ≤ n × 2 ≤ 2,147,483,647 |
varchar[(n)] | | ≤ n ≤ 8,000 |
Long Text and Binary | image | dep. 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.
|
ntext | 7, dep. 2005 |
nvarchar(max) | 2005 |
text | dep. 2005 |
varbinary(max) | 2005 |
varchar(max) | 2005 |
Special | hierarchyid | 2008 | A slash-separated path: /1/3/ |
rowversion | | 8 | |
sql_variant | 2000 | Stores any datatype except text, ntext, image, timestamp, and sql_variant (max 8016 bytes). |
table | 2000 | Faster than temporary tables. declare @name table ( … table definition … ) |
uniqueidentifier | 7 | 16 |
xml | 2005 | 16 (in-row pointer) | XML data with a schema is stored as a parsed tree. |