• You guys really need to learn english. There was rarely, if ever, a better written question.

    It clearly stated to execute 3 batches separately with begin / end points in the code.

    I just would like to add to the short explaination that the recompile speeds up the query because the row estimation is better which gives a different & better plan to execute.

    Table variables estimate to 1 row which is way wrong in this case and causes the "bad" plan.