Data Type Name | Class | Size in Bytes | Nature of the Data |
Bit | Integer | 1 | The size is somewhat misleading. The first bit data type in a table takes up one byte; the next seven make use of the same byte. Allowing nulls causes an additional byte to be used. |
Bigint | Integer | 8 | This just deals with the fact that we use larger and larger numbers on a more frequent basis. This one allows you to use whole numbers from –263 to 263–1. That’s plus or minus about 92 quintrillion |
Int | Integer | 4 | Whole numbers from –2,147,483,648 to 2,147,483,647. |
SmallInt | Integer | 2 | Whole numbers from –32,768 to 32,767. |
TinyInt | Integer | 1 | Whole numbers from 0 to 255. |
Decimal or Numeric | Decimal/ Numeric | Varies | Fixed precision and scale from –1038–1 to 1038–1. The two names are synonymous. |
Money | Money | 8 | Monetary units from –263 to 263 plus precision to four decimal places. Note that this could be any monetary unit, not just dollars. |
SmallMoney | Approximate Numerics | 4 | Accepts an argument (for example, Float(20)) that determines size and precision. Note that the argument is in bits, not bytes. Ranges from –1.79E + 308 to 1.79E + 308. |
Float (also a synonym for ANSI Real) | Approximate Numerics | Varies | Accepts an argument (for example, Float(20)) that determines size and precision. Note that the argument is in bits, not bytes. Ranges from –1.79E + 308 to 1.79E + 308. |
DateTime | Date/Time | 8 | Date and time data from January 1, 1753, to December 31, 9999, with an accuracy of three-hundredths of a second. |
SmallDateTime | Date/Time | 4 | Date and time data from January 1, 1900, to June 6, 2079, with an accuracy of one minute. |
Cursor | Special Numeric | 1 | Pointer to a cursor. While the pointer only takes up a byte, keep in mind that the result set that makes up the actual cursor also takes up memory—exactly how much will vary depending on the result set. |
Timestamp/ rowversion | Special Numeric (binary) | 8 | Special value that is unique within a given database. Value is set by the database itself automatically every time the record is inserted or updated, even though the timestamp column wasn’t referred to by the UPDATE statement. (You’re actually not allowed to update the timestamp field directly.) |
UniqueIdentifier | Special Numeric (binary) | 16 | Special Globally Unique Identifier (GUID). Is guaranteed to be unique across space and time. |
Char | Character | Varies | Fixed-length character data. Values shorter than the set length are padded with spaces to the set length. Data is non-Unicode. Maximum specified length is 8,000 characters. |
VarChar | Character | Varies | Variable-length character data. Values are not padded with spaces. Data is non-Unicode. Maximum specified length is 8,000 characters, but you can use the max keyword to indicate it as essentially a very large character field (up to 2^31 bytes of data). |
Text | Character | Varies | Legacy support as of SQL Server 2005. Use varchar(max) instead. |
NChar | Unicode | Varies | Fixed-length Unicode character data. Values shorter than the set length are padded with spaces. Maximum specified length is 4,000 characters. |
NVarChar | Unicode | Varies | Variable-length Unicode character data. Values aren’t padded. Maximum specified length is 4,000 characters, but you can use the max keyword to indicate it as essentially a very large character field (up to 2^31 bytes of data). |
Ntext | Unicode | Varies | Like the Text data type, this is legacy support only. In this case, use nvarchar(max). Variablelength Unicode character data |
Binary | Binary | Varies | Fixed-length binary data with a maximum length of 8,000 bytes. |
VarBinary | Binary | Varies | Variable-length binary data with a maximum specified length of 8,000 bytes, but you can use the max keyword to indicate it as essentially a LOB field (up to 2^31 bytes of data). |
Image | Binary | Varies | Legacy support only as of SQL Server 2005. Use varbinary(max) instead. |
Table | Other | Special | This is primarily for use in working with result sets, typically passing one out of a User Defined Function. Not usable as a data type within a table definition. |
Sql_variant | Other | Special | This is loosely related to the Variant in VB and C++. Essentially it’s a container that enables you to hold most other SQL Server data types in it. That means you can use this when one column or function needs to be able to deal with multiple data types. Unlike VB, using this data type forces you to cast it explicitly to convert it to a more specific data type. |
XML | Character | Varies | Defines a character field as being for XML data. Provides for the validation of data against an XML Schema and the use of special XMLoriented functions. |
Tags:
Database