In Microsoft® SQL ServerTM, each column, local variable, expression, and parameters have a related data type, which is the characteristic of the data type (integer, characters, money, etc.) that specify the object. SQL Server provides system data type sets that define all data types that can be used with SQL Server. The data type set provided by the system is listed below.
User-defined data types can be defined, which is an alias for the data type provided by the system. For more information on user-defined data types, see sp_addtype and create user-defined data types.
When two expressions with different data types, sorting rules, accuracy, small digits or lengths are combined by operators:
The data type of the resulting value is determined by applying a priority order rule of the data type to the data type of the input expression. For more information, see the priority order of the data type. If the result data type is CHAR, VARCHAR, TEXT, NCHAR, NVARCHAR, or NTEXT, the sequencing rule of the result value is determined by the priority sequential rule of the sorting rule. For more information, see the priority order of the sorting rules. The accuracy of the result, the number of decimalities and the length depends on the accuracy of the input expression, the number of digits and lengths. For more information, see the accuracy, decimal digits, and length.
SQL Server provides data type synonyms for SQL-92 compatibility. For more information, see the data type synonym.
Exact number
Integer
Bigint
The integer data (all numbers) from -2 ^ 63 (-922372036854777, 58) to 2 ^ 63-1 (922372036854775807).
int
The integer data (all numbers) from -2 ^ 31 (-2, 147, 483, 648) to 2 ^ 31 - 1 (2, 147, 483, 647).
Smallint
The integer data from -2 ^ 15 (-32, 768) to 2 ^ 15 - 1 (32, 767).
Tinyint
Integer data from 0 to 255.
Bit
Bit
1 or 0 integer data.
Decimal and Numeric
Decimal
The fixed accuracy and decimal digital data from -10 ^ 38 1 to 10 ^ 38 -1.
Numeric
Function is equivalent to Decimal.
Money and Smallmoney
Money
The currency data value is from -2 ^ 63 (-922, 337, 203, 685, 477.5808) and 2 ^ 63 - 1 ( 922, 337, 203, 685, 477.5807), and is accurate to thousands of thousands of currency units.
Smallmoney
The currency data value is between -214, 748.3648 and 214, 748.3647, which is accurate to thousands of currency units.
Approximate number
Float
Floating point 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, 1999 to January 31, 9999, accurate to 3 seconds (or 3.33 ms).
SmallDateTime
Date and time data from January 1, 2079 from January 1, 1900, accurate to minutes.
String
charr
The fixed length of non-Unicode character data, the maximum length is 8,000 characters.
VARCHAR
The non-Unicode data of variable length is up to 8,000 characters.
TEXT
The non-Unicode data of variable length, the maximum length is 2 ^ 31 - 1 (2, 147, 483, 647) characters.
Unicode string
nchar
The fixed length Unicode data, the maximum length is 4,000 characters. nvarchar
Variable length Unicode data, its maximum length is 4,000 characters. SysName is a system-defined data type that provides user-defined data, which is functionally equivalent to NVARCHAR (128) for reference database object names.
NText
Variable length Unicode data, its maximum length of 2 ^ 30 - 1 (1, 073, 741, 823) characters.
Binary string
binary
Secondary binary data for fixed length, which is 8,000 bytes.
Varbinary
The binary data of variable length, its maximum length of 8,000 bytes.
Image
Binary data of variable length, the maximum length of 2 ^ 31 - 1 (2, 147, 483, 647) bytes.
Other data types
Cursor
Quote for cursors.
SQL_VARIANT
A data type that stores the various data types supported by SQL Server (except for the except for NTEXT, TIMESTAMP, and SQL_VARIANT) values.
TABLE
A special data type that stores the result set for later processing.
Timestamp
The unique number of the database range is also updated each time you update.
UniqueIdentifier
Global Unique Identifier (GUID).