It's failing during the metadata check in the pre-compile, not during actual runtime. This is usually ran into when you're dealing with altered #tmp tables in repeated script runs when you don't explicitly drop the table at the tail.
There's no real way to avoid it, unfortunately. That you need a transaction offsets the ability to use GO between them to split the scripts apart to avoid the failing portions.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA