In SQL Server, each column, local variable, expression, and parameter have a related data type. A data type is an attribute that specifies the type of data that the object can hold:integer data, character data, Moneta RY data, date and time data, binary strings, and so on.
SQL Server supplies a set of system data types that define all the types of data so can be used with SQL Server. You can also define your own data types in Transact-SQL or the Microsoft. NET Framework. Alias data types is based on the system-supplied data types. For more information on alias data types, seeworking with alias data types. user-defined types obtain their characteristics from the methods and operators of a class this you create by using one of The programming languages support by the. NET Framework. For more information, see Working with CLR user-defined Types.
When the expressions that has different data types, collations, precision, scale, or length is combined by an Operato R, the characteristics of result is determined by the following:
-
The data type of the result is determined by applying the rules of data type precedence to the data types of The input expressions. For more information, Seedata Type precedence (Transact-SQL).
-
The collation of the result is determined by the rules of collation precedence when the result data type Is char, varchar, text, nchar, nvarchar, Or ntext. For more information, see collation precedence (Transact-SQL).
-
The precision, scale, and length of the result depend on the precision, scale, and length of the input expressions. For + information, see precision, scale, and LENGTH (Transact-SQL).
SQL Server provides data type synonyms for ISO compatibility. For more information, see Data Type synonyms (Transact-SQL).
Data Type Categories
Data types in SQL Server is organized into the following categories:
Exact Numerics |
Unicode character strings |
Approximate Numerics |
Binary strings |
Date and Time |
Other data types |
Character strings |
|
In SQL Server, based on their storage characteristics, some data types is designated as belonging to the following groups :
Large Value data types: varchar (max), nvarchar (max), and varbinary (max)
Large Object Data types: text, ntext, image, varchar (max), nvarchar (max), varbinary (max), and xml
Note |
Sp_help Returns-1 as the length for the Large-value and XML data types. |
Exact Numerics
bigint |
Numeric |
Bit |
smallint |
Decimal |
SmallMoney |
Int |
tinyint |
Money |
|
Approximate Numerics
Date and Time
Date |
DateTimeOffset |
DateTime2 |
smalldatetime |
Datetime |
Time |
Character Strings
Unicode Character Strings
Binary Strings
Other Data Types
Cursor |
Timestamp |
HierarchyID |
uniqueidentifier |
sql_variant |
Xml |
Table |
|
SQL Server R2--data Types