join 2 users through union and leave the result in a temporary table

2

I have 2 queries to different tables, which have the same structure, but different records. I can combine both selects with UNION, and I want this result to be recorded in a temporary table.

Querys are simple

Select * from tabla A
union
Select * from tabla B

What I need (and it does not work for me) is that the result of this Union, is in a temporary table

try this, but it does not work for me

Select * from tabla A
union
Select * from tabla B
Into #tablaTemP

pls help. thanks

    
asked by Luis Gabriel Fabres 10.05.2018 в 20:34
source

1 answer

1

You are simply using the INTO Tabla statement on the wrong side; must go immediately before the first FROM :

Select * 
Into #tablaTemP
from tabla A

union

Select * 
from tabla B;
    
answered by 10.05.2018 / 20:36
source