MSSQL data type and length limit detailed description _mssql

Source: Internet
Author: User
Tags datetime numeric mssql
SQL Server provides a set of system data types that define all data types that can be used with SQL Server. The set of data types provided by the system is listed below.

You can define a user-defined data type, which is an alias for the data type provided by the system. For more information about user-defined data types, see sp_addtype and creating user-defined data types.
When two expressions with different data types, collations, precision, decimal digits, or lengths are grouped by operators:
The data type of the resulting value is determined by applying the precedence rule of the data type to the data type of the input expression. For more information, see Priority order for data types.


If the result data type is char, varchar, text, nchar, nvarchar, or ntext, the collation of the result value is determined by the precedence rule of the collation. For more information, see Prioritization of collations.


The precision, scale, and length of the result depend on the precision, scale, and length of the input expression. For more information, see Precision, Number of decimal places, and length.
SQL Server provides data type synonyms for SQL-92 compatibility. For more information, see Data type synonyms.

Exact number

Integer

bigint integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807).

int from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) of integer data (all numbers).

smallint integer data from -2^15 (-32,768) to 2^15-1 (32,767).

Tinyint the integer data from 0 to 255.

Bit

Integer data for bit 1 or 0.

Decimal and numeric

Decimal data from -10^38 +1 to 10^38–1 for fixed precision and decimal digits.

The numeric function is equivalent to decimal.


Money and SmallMoney

The money currency data value is between -2^63 ( -922,337,203,685,477.5808) and 2^63-1 (+922,337,203,685,477.5807), and is accurate to 10 per thousand of the monetary unit.

The smallmoney currency data value is between -214,748.3648 and +214,748.3647, accurate to 10 per thousand of the monetary unit.


Approximate numbers

Float precision numbers from -1.79e + 308 to 1.79E + 308.

Real floating-point precision numbers from -3.40e + 38 to 3.40E + 38.


DateTime and smalldatetime

DateTime date and time data from January 1, 1753 to December 31, 9999, accurate to 3% seconds (or 3.33 milliseconds).

smalldatetime date and time data from January 1, 1900 to June 6, 2079, accurate to minutes.

String

Char fixed-length non-Unicode character data with a maximum length of 8,000 characters.

varchar variable-length non-Unicode data, up to 8,000 characters long.

Text variable-length non-Unicode data with a maximum length of 2^31-1 (2,147,483,647) characters.

Unicode string

NChar fixed-length Unicode data with a maximum length of 4,000 characters.

Nvarchar variable-length Unicode data with a maximum length of 4,000 characters. sysname is a system that provides a user-defined data type, functionally equivalent to nvarchar (128), and is used to reference database object names.

ntext variable-length Unicode data with a maximum length of 2^30-1 (1,073,741,823) characters.


Binary strings

Binary fixed-length binary data with a maximum length of 8,000 bytes.
varbinary variable-length binary data with a maximum length of 8,000 bytes.
Image variable-length binary data with a maximum length of 2^31-1 (2,147,483,647) bytes.


Other data types

A reference to the cursor cursor.

sql_variant
A data type that stores the values of various data types (except text, ntext, timestamp, and sql_variant) supported by SQL Server.

Table
A special data type that stores a result set for later processing.

Timestamp
A database-wide unique number that is updated each time the row is updated.

uniqueidentifier
A globally unique identifier (GUID).

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.