我得到了
INSERT INTO TABLE3
SELECT * FROM table1
UNION ALL
if object_id('tempdb..#temp') is not null drop table tempdb..#temp
select * into #temp from (SELECT * FROM table2) then original SELECT for UNION
但我收到语法错误?
任何帮助将不胜感激。谢谢
答案 0 :(得分:3)
我不确定你想要达到的目标,但我认为它会帮助你在插入之前删除表格。
if object_id('tempdb..#temp') is not null
drop table tempdb..#temp
SELECT * INTO #temp
FROM table2
INSERT INTO TABLE3
SELECT *
FROM table1
UNION ALL
SELECT *
FROM #temp