Table. Field Types and Appropriate Uses
Field Type | Description | Storage |
---|---|---|
Bigint | New to SQL Server 2000. Can hold numbers ranging from 263 to 263. | 8 bytes. |
Binary | Holds from 1 to 8,000 bytes of fixed-length binary data. | Whatever is in the column, plus 4 additional bytes. |
Bit | Can hold a value of either 1 or 0. Nulls not allowed. | 8-bit fields take up 1 byte of data. |
Char | Holds from 1 to 8,000 bytes of fixed-length non-Unicode characters. | The number of bytes corresponds to the length of the field (regardless of what is stored in it). |
DateTime | Holds valid dates from January 1, 1753 to December 31, 9999. | 4 bytes. |
Used for numbers with fixed precision and scale. When maximum precision is used, values can range from 1038 1 to 1038 1. Scale must be less than or equal to the precision. | Depends on the precision. | |
Float | Can hold positive and negative numbers from 1.79E + 308 to 1.79E + 308. It offers binary precision up to 15 digits. | 8 bytes. |
Image | Consists of linked data pages of binary data. It can contain up to 2,147,483,647 bytes of binary data. | Depends on what is stored in it. |
Int | Can store whole numbers from, 2,147,483,648 to 2,147,483,647. | 4 bytes. |
Money | Can store decimal data ranging from 263 to 263, scaled to four digits of precision. It offers accuracy to 1/10,000 of a monetary unit. | 8 bytes. |
NChar | Can contain from 1 to 4,000 Unicode characters. | Twice the amount of bytes of Char. Corresponds to the length of the field (regardless of what is stored in it). |
NText | Can hold data up to 1,073,741,823 Unicode characters. | Each character takes 2 bytes of storage. |
Numeric | Used for numbers with fixed precision and scale. When maximum precision Values can range from 1038 to 1 to 1038 +1. | Depends on the precision. |
NVarChar | Can contain from 1 to 4,000 Unicode characters. | 2 bytes per character stored. |
NVarChar(MAX) | ||
Real | A smaller version of float. Contains a single-precision floating-point number from 3.40E + 38 to 3.40E + 38. | 4 bytes. |
SmallDateTime | Consists of two 2-byte integers. Can store dates only between 1/1/1900 and 6/6/2079. | 4 bytes. |
SmallInt | A smaller version of int. Can store values between 32,768 and 32,767. | 2 bytes. |
SmallMoney | ||
A smaller version of money. Can store decimal data scaled to four digits of precision. Can store values from 214,748.3648 to +214,748.3647. | 4 bytes. | |
SQL_Variant | New to SQL 2000. Can store int, binary, and char values. Is a very inefficient data type. | Varies. |
Text | Stores up to 2,147,483,647 characters of non-Unicode data. | 1 byte for each character of storage. |
TimeStamp | Generates a unique binary value that SQL Server automatically creates when a row is inserted and that SQL Server updates every time that the row is edited. | 8 bytes. |
TinyInt | Stores whole numbers from 0 to 255. | 1 byte. |
UniqueIdentifier | A globally unique identifier (GUID) that is automatically generated when the NEWID() function is used. | 16 bytes. |
VarBinary | Can hold variable-length binary data from 1 to 8000 bytes. | Varies from 1 to 8000 bytes. |
VarBinary(MAX) | ||
VarChar | A variable-length string that can hold 1 to 8,000 non-Unicode characters. | 1 byte per character stored. |
VarChar(MAX) | ||
XML |