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 |
sarahmfr
Posting Yak Master
214 Posts |
Posted - 2012-06-15 : 15:04:43
|
Hello all,I am having a stored procedurethat pulls information from several tables and I want to populate those to one temporary tableNow I am using unionexample select forumtitle as tile , opendate as start, closedate as [end] from forum.threads where xxxunionselect journaltitle as title, opendate as start, closedate as endfrom journal.sectionjournatwhere xxxxand so onhow can I do that using #temptableThankssarah |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-15 : 16:10:57
|
is table already present or you want to create it on the fly?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2012-06-15 : 19:27:39
|
If the temp table does not exist yet and you want it created by your SELECT statement, just put the INTO #temptable before the first FROM clause:SELECT Col1, Col2INTO #TempTableFROM Table1UNION SELECT Col1, Col2FROM Table2SQL Server Helperhttp://www.sql-server-helper.com/tips/tip-of-the-day.aspx |
 |
|
|
|
|