SQL Server Data types

Source: Internet
Author: User

Characters are:
char (n) a fixed-length string.   A maximum of 8,000 characters. N
varchar (n) variable-length string. A maximum of 8,000 characters.
VARCHAR (max) variable-length string. A maximum of 1,073,741,824 characters.
The text variable-length string. Up to 2GB character data.
NCHAR (n) fixed-length Unicode data. A maximum of 4,000 characters.
nvarchar (n) variable-length Unicode data. A maximum of 4,000 characters.
nvarchar (max) variable-length Unicode data. A maximum of 536,870,912 characters.
ntext variable-length Unicode data. Up to 2GB character data.
Unicode nvarchar () is generally used;
2 binary
Bit allows 0, 1, or NULL
Binary (n) fixed-length binary data. Up to 8,000 bytes.
varbinary (n) variable-length binary data. Up to 8,000 bytes.
varbinary (max) variable-length binary data. Up to 2GB bytes.
Image variable-length binary data. Up to 2GB.
Numeric type
tinyint allows all numbers from 0 to 255. 1 bytes
smallint allows all numbers from 32,768 to 32,767. 2 bytes
int allows all numbers from 2,147,483,648 to 2,147,483,647. 4 bytes
BigInt allows all numbers between 9,223,372,036,854,775,808 and 9,223,372,036,854,775,807. 8 bytes
Decimal (p,s) fixed precision and proportional number. Allows a number from -10^38 +1 to 10^38-1. The P parameter indicates the maximum number of digits that can be stored (left and right of the decimal point). P must be a value between 1 and 38. The default is 18. The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value between 0 and P.   The default is 0. 5-17 bytes
numeric (p,s) fixed precision and proportional numbers. Allows a number from -10^38 +1 to 10^38-1. The P parameter indicates the maximum number of digits that can be stored (left and right of the decimal point). P must be a value between 1 and 38. The default is 18. The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value between 0 and P.   The default is 0. 5-17 bytes
SmallMoney the currency data between -214,748.3648 and 214,748.3647. 4 bytes
Money data between -922,337,203,685,477.5808 and 922,337,203,685,477.5807. 8 bytes
Float (n) floating precision digital data from -1.79e + 308 to 1.79E + 308. The parameter n indicates whether the field holds 4 bytes or 8 bytes. Float (24) holds 4 bytes, while float (53) holds 8 bytes.    The default value for N is 53. 4 or 8 bytes
Real floating precision digital data from -3.40e + 38 to 3.40E + 38. 4 bytes
Date type
DateTime is from January 1, 1753 to December 31, 9999 with a precision of 3.33 milliseconds. 8 bytes
DateTime2 from January 1, 1753 to December 31, 9999, the accuracy is 100 nanoseconds. 6-8 bytes
smalldatetime from January 1, 1900 to June 6, 2079, the accuracy is 1 minutes. 4 bytes
Date stores only dates.   From January 1, 01 to December 31, 9999. 3 bytes
Time is stored only.   The accuracy is 100 nanoseconds. 3-5 bytes
The DateTimeOffset is the same as datetime2, plus the time zone offset. 8-10 bytes
Timestamp stores a unique number that is updated whenever a row is created or modified. The timestamp is based on the internal clock and does not correspond to real time. There can be only one timestamp variable per table.

Other types
Sql_variant stores data of up to 8,000 bytes of different data types, in addition to text, ntext, and timestamp.
uniqueidentifier stores the global identifier (GUID).
XML to store XML formatted data. Up to 2GB.
The cursor stores a reference to a pointer used for a database operation.
Table stores the result set for later processing.

SQL Server Data types

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.