String types:
Data type | Description |
---|---|
char(n) | Fixed width character string. Maximum 8,000 characters |
varchar(n) | Variable width character string. Maximum 8,000 characters |
text | Variable width character string. Maximum 2GB of text data |
nchar | Fixed width Unicode string. Maximum 4,000 characters |
nvarchar | Variable width Unicode string. Maximum 4,000 characters |
ntext | Variable width Unicode string. Maximum 2GB of text data |
Number types:
Data type | Description | Storage |
---|---|---|
tinyint | Allows whole numbers from 0 to 255 | 1 byte |
smallint | Allows whole numbers between -32,768 and 32,767 | 2 bytes |
int | Allows whole numbers between -2,147,483,648 and 2,147,483,647 | 4 bytes |
bigint | Allows whole numbers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 | 8 byte |
decimal(p,s) | Allows decimal numbers from -10^38 +1 to 10^38 –1 The p parameter indicates the maximum number of digits that can be stored. Value must be between 1 and 38. Default is 18. The s parameter indicates the maximum number of decimal digits to be stored. Value must be between 0 to p. Default value is 0. | 5-17 byte |
numeric(p,s) | Same as decimal | 5-17 byte |
float | Floating precision number from -1.79E+ 308 to 1.79E + 308. | 8 byte |
real | Floating precision number from -3.40E + 38 to 3.40E + 38 | 4 byte |
Date types:
Data type | Description | Storage |
---|---|---|
datetime | From January 1, 1753 to December 31, 9999. Format: 'YYYY-MM-DD HH:MM:SS' | 8 byte |
datetime2 | From January 1, 0001 to December 31, 9999. Format: 'YYYY-MM-DD HH:MM:SS' | 6-8 bytes |
smalldatetime | From January 1, 1900 to June 6, 2079. Format: 'YYYY-MM-DD HH:MM:SS' | 4 bytes |
date | Store a date only. From January 1, 0001 to December 31, 9999. In a Format 'YYYY-MM-DD' | 3 byte |
time | Store a time only to an accuracy of 100 nanoseconds | 3-5 byte |