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 |
drewsalem
Constraint Violating Yak Guru
304 Posts |
Posted - 2007-07-05 : 10:40:53
|
Hi is it not possible to use union with select into?Select blah From blahunion allSelect blah2 from blah2into #temptableCheersDrew---------------------"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK." |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-05 : 10:44:35
|
Select * into #temptablefrom(Select blah From blahunion allSelect blah2, from blah2) TMadhivananFailing to plan is Planning to fail |
 |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-07-05 : 10:47:28
|
The INTO clause must be after the first SELECT statement:Select blah From blahINTO #temptableunion allSelect blah2, from blah2SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
drewsalem
Constraint Violating Yak Guru
304 Posts |
Posted - 2007-07-05 : 10:54:17
|
quote: The INTO clause must be after the first SELECT statement:Select blah From blahINTO #temptableunion allSelect blah2, from blah2
I tried that, but it didn't appear to work for me. Maybe i typoed.Madhivanan's works a treat though. What's the T at the end of the statement?Select * into #temptablefrom(Select blah From blahunion allSelect blah2, from blah2) T Drew---------------------"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK." |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-07-05 : 11:04:29
|
It's called an alias (to give name to the derived table)Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-07-05 : 11:06:49
|
quote: Originally posted by drewsalem
quote: The INTO clause must be after the first SELECT statement:Select blah From blahINTO #temptableunion allSelect blah2, from blah2
I tried that, but it didn't appear to work for me. Maybe i typoed.
The INTO must be after the first SELECT but before the FROM clause of that first SELECT:Select blah From blahINTO #temptableFROM YourTable1union allSelect blah2, from blah2FROM YourTable2SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
|
|
|
|