473,698 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SELECT INTO Question?

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
2 2869
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******** ******@TK2MSFTN GP12.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
Thank you!

/Lars

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Op******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP12.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5190
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers using check boxes. For example, a question such as
3
6462
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
2
9764
by: marco | last post by:
Dear List, as it seems, MS SQL as used in Access does not allow a select INTO within a UNION query. Also, it seems that a UNION query can not be used as a subquery. Maybe my (simplified) problem can avoid these technicalities: the original table has columns A1, A2, B1, B2, C1, C2.
6
1163
by: @sh | last post by:
Need help again! Here's the head script... ---------------------------------------------------------------------------------------- function Ash_ChangePicFromSelect(TheSource,TheDestination) { value = TheSource.options.value; if (value != '') if (document.images) // document.images.src = value; document.images(TheDestination).src = value; }
1
2222
by: Christopher DeMarco | last post by:
Hi all... I've written a class to provide an interface to popen; I've included the actual select() loop below. I'm finding that "sometimes" popen'd processes take "a really long time" to complete and "other times" I get incomplete stdout. E.g: - on boxA ffmpeg returns in ~25s; on boxB (comparable hardware,
5
2175
by: GTi | last post by:
Whats wring with this code? <select class=EditField size="1" name="PlantUnitID" title="Select line"> <option value="0" >Standalone Unit</option> <option value="1" selected >Connected Unit 1</option> <option value="1" selected >Connected Unit 2</option> </select> <span onclick="NewWindow('pluginpage.html?EditUnitGUID='+this.form.PlantUnitID.options.value+'&DoPostBack=1','namexx',200,310);"
2
3247
by: Eitan | last post by:
Hello, I want a solutions for a compicateds sql select statments. The selects can use anything : views, stored procedures, analytic functions, etc... (not use materialized view, unless it is neccessary). question 1) The selects can use anything : views, stored procedures, analytic functions, etc...
21
17440
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know), but each answer is given a different point value for each question. For instance, question 1 might ask "Do you like candy?" and if you answer Yes you will get +1, No will earn you -1, and Don't know will net you zero points. The next question might...
17
3130
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note that I am using Allen Browne's multi-select list box for a report as a guide. I should also note that my access skills are not the best so I may need some explaining on certain things. First let me give some background on the database: I have a...
25
5394
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.