Solved

SELECT SELECT SQL Query Result

Posted on 2007-12-05
6
327 Views
Last Modified: 2010-04-21
I have a SQL query syntax and when i run it, it will return result table in SQL SERVER. What I want is to query using the result. Is that any solution?

Eg. The result returned is a table, and i wish to write select syntax base on the result.
0
Comment
Question by:mycacha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20417116
If this is a stored procedure then you cannot access the result table
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20417122
If it has no side effects, you can turn the SProc into a Table function, so that you can treat it like a table, i.e.

SELECT * FROM dbo.MyTableFunction()
0
 
LVL 25

Accepted Solution

by:
imitchie earned 50 total points
ID: 20417127
If you query is something like

SELECT A,B,C from Table

You can requery the result using

SELECT * FROM
(
SELECT A,B,C from Table
) INNERTABLE
WHERE ....

i.e. put the whole thing in a subquery, give the subquery an alias (i.e. INNERTABLE) and treat it like any table
(which contains the columns of the inner SELECT)
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:mycacha
ID: 20417128
Good idea!
can explain detail on how to convert the result set to table?
0
 

Author Comment

by:mycacha
ID: 20417156
Yea, thats the keyword. INNERTABLE. Thanks yea,
0
 

Author Closing Comment

by:mycacha
ID: 31413050
Excellent!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question