• Excellent question in that to understand the result, you have to step through the entire process.

    --The statements compile.

    --Each "select" is executed.

    --Then the two result sets are combined to effect the Union. That's where the error occurs.

    That's why even though the alpha character "B" was earlier in the code, the execution tried to convert it to the higher precedence integer type to satisfy the column type forced by the later value "4".

    The compiler couldn't catch this as it won't look at the values, only the datatypes. If the character input had been a digit (in quotes), it would run. This works:

    select '3'

    union

    select 4