SQL Advanced (8) data type character string:
Data Type |
Description |
Storage |
CHAR (n) |
A fixed-length string. A maximum of 8,000 characters. |
N |
VARCHAR (n) |
A variable-length string. A maximum of 8,000 characters. |
|
varchar (max) |
A variable-length string. A maximum of 1,073,741,824 characters. |
|
Text |
A variable-length string. Up to 2GB character data. |
|
Unicode string:
Data Type |
Description |
Storage |
NCHAR (n) |
Fixed-length Unicode data. A maximum of 4,000 characters. |
|
nvarchar (n) |
Variable-length Unicode data. A maximum of 4,000 characters. |
|
nvarchar (max) |
Variable-length Unicode data. A maximum of 536,870,912 characters. |
|
ntext |
Variable-length Unicode data. Up to 2GB character data. |
|
Binary Type:
Data Type |
Description |
Storage |
Bit |
Allow 0, 1, or NULL |
|
Binary (n) |
Fixed-length binary data. Up to 8,000 bytes. |
|
varbinary (n) |
Variable-length binary data. Up to 8,000 bytes. |
|
varbinary (max) |
Variable-length binary data. Up to 2GB bytes. |
|
Image |
Variable-length binary data. Up to 2GB. |
|
Number type:
Data Type |
Description |
Storage |
tinyint |
All numbers from 0 to 255 are allowed. |
1 bytes |
smallint |
All numbers from 32,768 to 32,767 are allowed. |
2 bytes |
Int |
All numbers from 2,147,483,648 to 2,147,483,647 are allowed. |
4 bytes |
bigint |
Allows all numbers between 9,223,372,036,854,775,808 and 9,223,372,036,854,775,807. |
8 bytes |
Decimal (P,s) |
Fixed-precision and proportional numbers. Allows a number from -10^38 +1 to 10^38-1. The P parameter indicates the maximum number of digits that can be stored (left and right of the decimal point). P must be a value between 1 and 38. The default is 18. The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value between 0 and P. The default is 0. |
5-17 bytes |
Numeric (P,s) |
Fixed-precision and proportional numbers. Allows a number from -10^38 +1 to 10^38-1. The P parameter indicates the maximum number of digits that can be stored (left and right of the decimal point). P must be a value between 1 and 38. The default is 18. The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value between 0 and P. The default is 0. |
5-17 bytes |
SmallMoney |
Currency data between -214,748.3648 and 214,748.3647. |
4 bytes |
Money |
Currency data between -922,337,203,685,477.5808 and 922,337,203,685,477.5807. |
8 bytes |
Float (n) |
Floating precision digital data from -1.79e + 308 to 1.79E + 308. The parameter n indicates whether the field holds 4 bytes or 8 bytes. Float (24) holds 4 bytes, while float (53) holds 8 bytes. The default value for N is 53. |
4 or 8 bytes |
Real |
Floating precision digital data from -3.40e + 38 to 3.40E + 38. |
4 bytes |
Date Type:
Data Type |
Description |
Storage |
Datetime |
From January 1, 1753 to December 31, 9999, the accuracy is 3.33 milliseconds. |
8 bytes |
DateTime2 |
From January 1, 1753 to December 31, 9999, the accuracy is 100 nanoseconds. |
6-8 bytes |
smalldatetime |
From January 1, 1900 to June 6, 2079, the accuracy is 1 minutes. |
4 bytes |
Date |
Only dates are stored. From January 1, 01 to December 31, 9999. |
3 bytes |
Time |
Storage time only. The accuracy is 100 nanoseconds. |
3-5 bytes |
DateTimeOffset |
Same as datetime2, plus time zone offset. |
8-10 bytes |
Timestamp |
Stores a unique number that is updated whenever a row is created or modified. The timestamp is based on the internal clock and does not correspond to real time. There can be only one timestamp variable per table. |
|
Other data types:
Data Type |
Description |
sql_variant |
Stores data of up to 8,000 bytes of different data types, except text, ntext, and timestamp. |
uniqueidentifier |
Stores the global identifier (GUID). |
Xml |
Stores XML formatted data. Up to 2GB. |
Cursor |
Stores a reference to a pointer used for a database operation. |
Table |
Stores the result set for later processing. |
SQL Advanced (8) data type