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:

  1. user-defined data types (highest)
  2. sql_variant
  3. xml
  4. datetime
  5. smalldatetime
  6. float
  7. real
  8. decimal
  9. money
  10. smallmoney
  11. bigint
  12. int
  13. smallint
  14. tinyint
  15. bit
  16. ntext
  17. text
  18. image
  19. timestamp
  20. uniqueidentifier
  21. nvarchar (including nvarchar(max) )
  22. nchar
  23. varchar (including varchar(max) )
  24. char
  25. varbinary (including varbinary(max) )
  26. binary (lowest)

See Also


Data Types (Transact-SQL)
Expressions (Transact-SQL)
CAST and CONVERT (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance