• I have rebooted the PC, restarted Query Analyser, loaded the script and hit the Run button. I still get the same error.

    The problem presumably is that the parser sees the temporary table being created in two places and assumes that it already will exist when it hits the second one (not understanding that it is conditional).

    Incidentally, the line number given with the error message is the bottom of the script; not any code referencing the temporary table.