Menu

SQL Server Data Type Precedence

When a SQL Server expression combines different data types, the lower-precedence type is converted to the higher-precedence type when an implicit conversion is supported. If it is not supported, SQL Server returns an error. This rule affects arithmetic and comparison expressions and other operations that combine values. Assignments also convert an expression to the declared type of the destination column or variable. See Microsoft’s data type precedence rules.

Precedence order

The list is ordered from highest to lowest precedence. SQL Server converts the lower-precedence operand toward the higher-precedence type when evaluating an expression.

Order Data type
1 User-defined data types
2 json (where supported)
3 sql_variant
4 xml
5 datetimeoffset
6 datetime2
7 datetime
8 smalldatetime
9 date
10 time
11 float
12 real
13 decimal
14 money
15 smallmoney
16 bigint
17 int
18 smallint
19 tinyint
20 bit
21 ntext
22 text
23 image
24 timestamp (rowversion)
25 uniqueidentifier
26 nvarchar, including nvarchar(max)
27 nchar
28 varchar, including varchar(max)
29 char
30 varbinary, including varbinary(max)
31 binary

The native json type is available in SQL Server 2025 and certain Azure SQL and Fabric services; earlier SQL Server releases do not have it as a system data type. SQL Server’s timestamp entry means rowversion, not a date or time value; the timestamp spelling is deprecated.

Example: int has higher precedence than varchar

In this expression, SQL Server tries to convert the varchar value to int before using + as addition:

DECLARE @value int = 1;

SELECT @value + '2' AS result;

The result is 3. If the string cannot be converted, SQL Server raises a conversion error:

SELECT @value + 'two';

For a failed conversion from text to int, see SQL Server Error 245. If concatenation is intended, convert the number to a character type explicitly:

SELECT CONVERT(varchar(10), @value) + ' items' AS result;

For arithmetic that exceeds an integer or aggregate result range, see SQL Server Error 8115: Arithmetic Overflow.

Choose column and parameter types that match the data being compared. For explicit conversion examples, see CONVERT() and TRY_CONVERT().