Wednesday, April 2, 2014

70-461 Training Kit Chapter 2, Lesson 2: Data Type Precedence & Data Conversion

Here's the note for data conversion and data type precedence in SQL Server, part of 70-461 exam training kit, chapter 2.

Data Conversion
SQL Server often cast data type with lower precedence to a data type with higher precedence.
Example:  2 + '2' = 4 because '2' is converted to an integer. Since an INT data type has higher precedence than a CHAR.

Data Type Precedence of some data type
User-defined (highest)
Xml
Datetime2
Datetime
Smalldatetime
Date
Time
Float
Real
Decimal
Money
Smallmoney
Bigint
Int
Smallint
Tinyint
Bit
Timestamp
Uniqueidentifier
Nvarchar
Nchar
Varchar
Char
Varbinary
Binary (lowest)

Microsoft 70-461 Training Kit

No comments:

Post a Comment