• You cannot add a column and insert a value on the same stored procedure...

    When sql server starts to execute the code it validates the script... In your case he sees tha t the alter statement is ok (without executing it) but when it gets to the insert statement it throws an error (invalid column)

    The solution is to move the alter table to another stored procedure.....

    PS: using exec, the code is only validated at runtime , that why you dont get aqn error

    To verify the issue try this

    between the alter and insert statement write a block that does nothing for 1 minute....

    You 'll see that the error will rise when you hit Run (on validation) and not after 1 minute (exec)