• Thank you for an excellent explanation Hugo. The code like this should not be present anywhere near production of course, but the question is definitely a good one. One of the interesting side effects of implicit int to varchar conversions is that if the int value does not fit then varchar is set to *. For example, in the original example, if @a is set to 100 instead of 10 then it cannot fit into @b-2 and this will cause @b-2 = *, which can be somewhat confusing for someone who is unaware of this side effect. For example:

    declare @a int;

    declare @b-2 varchar(2);

    set @a = 100;

    set @b-2 = ' ' + @a + 2;

    select @b-2;

    The result is

    ----

    *

    This behavior is specific to int to varchar conversions only, other types such as smallint or bigint will cause the code to raise error.

    Oleg