Reputation: 95
I have two temp tables, #trial1
and #trial2
, with values in them. I want to create one permanent table from joining the two existing temp tables. Here are the structures of the tables.
What I have:
table: #trial1
columns: [uID],[SVN],[IN]
table: #trial2
columns: [uID],[PLE],[TS]
What I want:
table: perm_table
columns: [SVN],[IN],[PLE],[TS]
So the two temp tables will have to join on [uID]
. How can I create one permanent table from joining the two temp tables?
Upvotes: 1
Views: 1092
Reputation: 50173
You seems want SELECT....INTO
:
select tr1.SVN, tr1.[IN], tr1.[PLE], tr2.[TS] into perm_table
from #trial1 tr1 inner join
#trial2 tr2
on tr1.uid = tr2.uid;
Upvotes: 1
Reputation: 312289
You can use the select-into syntax:
SELECT [SVN], [IN], [PLE], [TS]
INTO perm_table
FROM #trial1 t1
JOIN #trial2 t2 ON t1.[uID] = t2.[uID]
Upvotes: 2