Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
MJ1210
Starting Member
3 Posts |
Posted - 2008-04-03 : 16:10:16
|
This may be a dumb question, but I can't seem to get the syntax right. I have two temp tables that have the same columns, I want to do a union on them and store the results in a temp table. Any ideas?Ie. select * from #tmpTable1unionselect * from #tmpTable2into #tmpTable3Thanks!!! |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-03 : 16:12:59
|
create # table(col.....)goinsert into #tableselect * from #tmpTable1unionselect * from #tmpTable2 |
|
|
MJ1210
Starting Member
3 Posts |
Posted - 2008-04-03 : 16:20:56
|
Thanks! So this will put it in a local temp table (ie. the temp table will be deleted when stored procedure is done executing?)Thanks so much! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-04 : 02:17:14
|
orSelect * into #tmpTable3 from(select * from #tmpTable1unionselect * from #tmpTable2) as tMadhivananFailing to plan is Planning to fail |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-04 : 02:18:43
|
quote: Originally posted by MJ1210 Thanks! So this will put it in a local temp table (ie. the temp table will be deleted when stored procedure is done executing?)Thanks so much!
If you create a temp table in a procedure, it would be dropped automatically once it is executedMadhivananFailing to plan is Planning to fail |
|
|
|
|
|