data types for SQL Server

Source: Internet
Author: User
Tags ranges

First big class: Integer data

The Bit:bit data type represents 0,1 or null, which means true,false. Consumes 1byte.
int: The positive and negative numbers are stored in 4 bytes. Storage range: -2^31 to 2^31-1.
SmallInt: Stores the positive and negative numbers in 2 bytes. Storage range: -2^15 to 2^15-1
Tinyint: is the smallest integer type, with only 1 bytes, range: 0 so ^8-1


Second class: Accurate numerical data

Numeric: The number represented can reach 38 bits, and the number of bytes used to store the data varies with the number of bits used for use.
Decimal: Similar to numeric


Class Three: Approximate floating-point numeric data

Float: Use 8 bytes to store data. Up to 53 bits. Range: -1.79E+308 to 1.79E+308.
Real: 24 digits, 4 bytes, numeric range: -3.04E+38 to 3.04E+38


Fourth Category: Date-time data

Datatime: Indicates that the time range can be expressed from 1753/1/1 to 9999/12/31, time can be expressed to 3.33/1000 seconds. Use 8 bytes.
smalldatetime: Indicates that the time range can be expressed from 1900/1/1 to 2079/12/31. Use 4 bytes.


Category five: String data

Char: Length is set, with a minimum of 1 bytes and a maximum of 8,000 bytes. The insufficient length will be blank.
VARCHAR: The length is also set, the shortest is 1 bytes, the longest is 8,000 bytes, the trailing blanks will be removed.
Text: Long-width is also set, the longest can be stored 2G of data.


Category six: Unincode string data

NCHAR: The length is set, the shortest is 1 bytes, and the maximum is 4,000 bytes. The length of the gap is blank. Storing one character requires 2 bytes.
Nvarchar: The length is set, the shortest is 1 bytes, and the maximum is 4,000 bytes. The trailing blanks are removed. Storing one character requires 2 bytes.
ntext: The length is set, the shortest is 1 bytes, the longest is 2G. The trailing blanks are removed and 2 bytes are required to store a single character.


Seventh Category: Currency data types

Money: The recorded amount ranges from 92233720368577.5808 to 92233720368577.5807. Requires 8 bytes.
SmallMoney: The recorded amount ranges from 214748.3648 to 214748.36487. Requires 4 bytes.


Eighth Class: Tag data

Timestamp: This data type is unique in every table! When one record in the table changes, the timestamp field of the record is automatically updated.
uniqueidentifier: The only record used to identify many tables within a database.


Nineth Category: Binary character string data

Binary: fixed-length binary string field with a minimum of 1 and a maximum of 8000.
varbinary: With binary difference is the data tail is 00 o'clock, varbinary will remove it
Image: A variable-length binary string with a maximum size of 2G.

data types for SQL Server

Related Article

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.