This is a follow-up question to http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_23480417.html
I have tried to wrap everything into a transaction, however, when it gets to the point of
SELECT * INTO table1 FROM (SELCT * FROM table1 UNION ALL SELECT * FROM table3) A
which actually should read:
SELECT * INTO table1 FROM (SELECT * FROM table2 UNION ALL SELECT * FROM table3) A
I get an error:
Invalid object name 'dbo.table2'.
table2 is the original table1, which was renamed at the start of the transaction. Any ideas how I can fix this?