Using temporary tables To make the entire process clear for yourself, treat a temporary table just like any other table. The only difference is it's prefixed with a #.
So to begin use a CREATE TABLE statement.
CREATE TABLE #testTemp(
temp_id IDENTITY(1,1) PRIMARY KEY CLUSTERED,
field1 varchar(255),
field2 int)
INSERT INTO #testTemp(field1,field2)
SELECT a.field1, a.field2
FROM a
INSERT INTO #testTemp(field1,field2)
SELECT b.field1, b.field2
FROM b
Not only you can insert into temporary tables, you can update them,
delete from them, etc.