Data Type Precedence (Transact-SQL)
When an operator combines two expressions of different data types, the rules for data type precedence specify that the data type with the lower precedence is converted to the data type with the higher precedence. If the conversion is not a supported implicit conversion, an error is returned. When both operand expressions have the same data type, the result of the operation has that data type.
SQL Server 2005 uses the following precedence order for data types:
- user-defined data types (highest)
- sql_variant
- xml
- datetime
- smalldatetime
- float
- real
- decimal
- money
- smallmoney
- bigint
- int
- smallint
- tinyint
- bit
- ntext
- text
- image
- timestamp
- uniqueidentifier
- nvarchar (including nvarchar(max) )
- nchar
- varchar (including varchar(max) )
- char
- varbinary (including varbinary(max) )
- binary (lowest)
See Also
Reference
Data Types (Transact-SQL)
Expressions (Transact-SQL)
CAST and CONVERT (Transact-SQL)