• webrunner - Tuesday, December 4, 2018 8:30 AM

    Thanks, nice question.

    Btw this returns 11 (or rather, '11'):
    DECLARE @s-2 VARCHAR(10) = '1'
    SELECT @s-2 += '1'
    SELECT @s-2

    - webrunner

    I suppose MS has implicit cast order documented somewhere. But this inspired me to do some testing. Where @s-2 is varchar and @i is int.
    @s-2 += '1' = '11'
    @s-2 += 1 = 2
    @i += '1' = '11'
    @i += 1 = 2

    I guess that's a bit intuitive. The type of the rhs value is being used to decide whether + is a string operator or a numeric operator.