SQL Server R2--data Types

Source: Internet
Author: User

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

Float

Real

Date and Time

Date

DateTimeOffset

DateTime2

smalldatetime

Datetime

Time

Character Strings

Char

varchar

Text

Unicode Character Strings

NChar

nvarchar

ntext

Binary Strings

Binary

varbinary

Image

Other Data Types

Cursor

Timestamp

HierarchyID

uniqueidentifier

sql_variant

Xml

Table

SQL Server R2--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.