By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,045 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,045 IT Pros & Developers. It's quick & easy.

SELECT INTO Question?

P: n/a
This code works:
SELECT * INTO #Temp From tbl_employee
SELECT * FROM #Temp
Drop TABLE #temp

This does not:
SELECT * INTO #Temp From (Select * FROM tbl_employee WHERE EMP_ID = @id
UNION Select * FROM tbl_employee2 EMP_ID = @id)
SELECT * FROM #Temp
Drop TABLE #temp

I need to get everything from a UNION select statement and I also need to
pass parameters to it so I can't use a view for this.

Is there any other way to make this work?

best regards/
Lars Netzel
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Wrong newsgroup, but try adding an AS X to the end of the SELECT * INTO:

SELECT * INTO #Temp From (
Select * FROM tbl_employee WHERE EMP_ID = @id
UNION
Select * FROM tbl_employee2 EMP_ID = @id
) AS ANYTHING

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Lars Netzel" <no****@doamin.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
This code works:
SELECT * INTO #Temp From tbl_employee
SELECT * FROM #Temp
Drop TABLE #temp

This does not:
SELECT * INTO #Temp From (Select * FROM tbl_employee WHERE EMP_ID = @id
UNION Select * FROM tbl_employee2 EMP_ID = @id)
SELECT * FROM #Temp
Drop TABLE #temp

I need to get everything from a UNION select statement and I also need to
pass parameters to it so I can't use a view for this.

Is there any other way to make this work?

best regards/
Lars Netzel

Nov 19 '05 #2

P: n/a
Thank you!

/Lars

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Op**************@TK2MSFTNGP09.phx.gbl...
Wrong newsgroup, but try adding an AS X to the end of the SELECT * INTO:

SELECT * INTO #Temp From (
Select * FROM tbl_employee WHERE EMP_ID = @id
UNION
Select * FROM tbl_employee2 EMP_ID = @id
) AS ANYTHING

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Lars Netzel" <no****@doamin.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
This code works:
SELECT * INTO #Temp From tbl_employee
SELECT * FROM #Temp
Drop TABLE #temp

This does not:
SELECT * INTO #Temp From (Select * FROM tbl_employee WHERE EMP_ID = @id
UNION Select * FROM tbl_employee2 EMP_ID = @id)
SELECT * FROM #Temp
Drop TABLE #temp

I need to get everything from a UNION select statement and I also need to
pass parameters to it so I can't use a view for this.

Is there any other way to make this work?

best regards/
Lars Netzel


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.