• Good question, but I'm not sure that the explanation is 100% correct.

    Because values from different data type families must be explicitly cast before being referenced in comparison predicates, the effects of the The values in the following table are examples of the rules regarding data type precedence.

    The values in the sql_variant column are not casted/converted into a common data type prior to the ORDER BY.

    If there is data from different data type families, then the values are sorted based on the data type family precedence.

    A quick example is if you add three values from the "Exact numeric" family and one from "Unicode" family.

    create table #test(id int, val sql_variant)

    insert into #test values(1,'2')

    insert into #test values(2,1)

    insert into #test values(3,3)

    insert into #test values(4,0)

    select *,sql_variant_property(val,'BaseType') from #test order by val

    /* Result */

    idval(No column name)

    12varchar

    40int

    21int

    33int

    As you can see when running this query, there is no casting of values between int and the varchar values in this column. The varchar (Unicode family) has lower precedence than int (Exact numeric family) and will always be lowest value.