• Great question. I got it wrong because I didn't know about the implicit conversion of string values containing only numbers.

    For example, this code throws the error I expected:

    declare @a int

    declare @b-2 varchar(2)

    set @a = 10

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

    select @a + @b-2

    Messages:

    Server: Msg 245, Level 16, State 1, Line 5

    Syntax error converting the varchar value ' a' to a column of data type int.

    While answering the question, I thought only of those cases (probably the vast majority) where I had used code like the code above (for concatenation in printing test values only, not for adding numbers), and in variably it included at least one non-numeric character. So I was biased to think that such code would always throw an error.

    This question is a nice corrective for my ignorance in that regard.

    Thanks,

    webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html