In Microsoftreg; SQL Server#8482; In, each column, local variable, expression, and parameter has an associated data type, which is a feature of specifying the data types that an object can hold (integer, character, money, and so on).
SQL Server provides a system data type set that defines 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 user-defined data types, which are aliases for system-provided data types. 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 numbers, or lengths are combined by an operator:
Determine the data type of the resulting value by applying the precedence rules of the data type to the data type of the input expression. For more information, see Prioritization of 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 Precedence of collation.
The precision, decimal, and length of the result depend on the precision, decimal, and length of the input expression. For more information, see Precision, Decimal places, and Length.
SQL Server provides data type synonyms for SQL-92 compatibility. For more information, see Synonyms for Data types.
Precise Numbers
The integer
Bigint Integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807).
Int Integer data (all numbers) from -2^31 (-2,147,483,648) to 2^ 31-1 (2,147,483,647).
Smallint Specifies the integer data from -2^15 (-32,768) to 2^ 15-1 (32,767).
Tinyint Specifies the integer from 0 to 255.
bit
Bit Integer data of 1 or 0.
A decimal and numeric
Decimal from -10^38 +1 to 10^38 — 1 for fixed precision and decimal number data.
Numeric is functionally equivalent to decimal.
Money and smallmoney
The money data value is between -2^63 (-922,337,203,685,477.5808) and 2^ 63-1 (+922,337,203,685,477.5807), accurate to ten thousandths of a monetary unit.
Smallmoney Currency data values between -214,748.3648 and +214,748.3647, accurate to ten thousandths of a currency unit
The approximate number
Float A float precision number from -1.79E + 308 to 1.79E + 308.
Real a floating point precision number 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 three hundredths of a second (or 3.33 milliseconds).
Smalldatetime Date and time data from January 1, 1900 to June 6, 2079, accurate to the minute.
string
Char Fixed-length non-Unicode character data with a maximum length of 8,000 characters.
Varchar Non-Unicode data of variable length, up to 8,000 characters.
Text Non-Unicode data of variable length, maximum length 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 the user-defined data type provided by the system. It is equivalent to nvARCHar (128) in function 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 string
Binary FIXED-length binary data, with a maximum length of 8,000 bytes.
Varbinary A variable length of 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
Cursor A reference to a cursor.
sql_variant
A data type that stores values of the various data types supported by SQL Server (except text, NTEXT, TIMESTAMP, and SQL_VARIANT).
table
A special data type that stores a result set for later processing.
timestamp
A unique number of database scope that is updated each time a row is updated.
uniqueidentifier
Globally unique identifier (GUID).