Common MSSQLServer Data Types

Source: Internet
Author: User
Category 1: Integer Data

Bit: the BIT data type is 0, 1 or null, which means true, False . Occupies 1 byte.

Int : Stores Positive and Negative Numbers in 4 bytes. The storage range is: - 2 ^ 31 to 2 ^ 31 - 1 .

Smallint: stores Positive and Negative Numbers in 2 bytes. The storage range is: - 2 ^ 15 to 2 ^ 15 - 1

Tinyint: The smallest integer type. It must be 1 byte in the range of 0 to this point. ^ 8 - 1  



Second category: exact value data



Numeric: The number can reach 38 BITs. The number of bytes used for data storage varies with the number of used bits.

Decimal : Similar to numeric



Category 3: Approximate floating point data



Float : Uses 8 bytes to store data. A maximum of 53 bits are allowed. The range is: - 1 . 79E + 308 to 1.79e + 308 .

Real: the number of digits is 24, with 4 bytes. The value range is: - 3 . 04e + 38 to 3.04e + 38  



Category 4: Date and Time Data



Datatime: indicates that the time range can be expressed from 1753 / 1 / 1 to 9999 / 12 / 31 , Time can be expressed as 3. 33 / 1000 seconds. 8 bytes are used.

Smalldatetime: indicates that the time range can be expressed from 1900 / 1 / 1 To 2079 / 12 / 31 . Use 4 bytes.



Category 5: String data



Char : The length is set. The shortest value is 1 byte and the maximum value is 8000 bytes. The insufficient length will be filled with blank space.

Varchar: The length is also set. The shortest value is 1 byte and the maximum value is 8000 bytes. The white space at the end is removed.

Text: the length and width are also set. up to 2 GB data can be stored.



Category 6: unincode string data



Nchar: The length is set. The minimum value is 1 byte and the maximum value is 4000 bytes. The length is left blank. 2 bytes are required to store a character.

Nvarchar: Specifies the length. The minimum length is 1 byte and the maximum length is 4000 bytes. The white space at the end is removed. It takes 2 bytes to store a character.

Ntext: The length is set. The minimum value is 1 byte and the maximum value is 2 GB. The white space at the end is removed. It takes 2 bytes to store a character.



Category 7: currency data type



Money: The recorded amount range is: - 92233720368577 . 5808 to 92233720368577. 5807 . 8 bytes required.

Smallmoney: The recorded amount range is: - 214748 . 3648 to 214748. 36487 . 4 bytes required.



Category 8: Mark data



Timestamp: the data type is unique in each table. ! when a record in the table is changed, the timestamp field of the record is automatically updated.
uniqueidentifier: used to identify the unique record of many tables in the database.
Category 9: binary string data
binary: A fixed-length binary string field. The minimum value is 1 and the maximum value is 8000.
varbinary: When the tail of the data is 00, varbinary removes it
image: a variable-length binary string, the maximum length is 2 GB.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.