Solved

SELECT SELECT SQL Query Result

Posted on 2007-12-05
6
324 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
  • 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Replication question 9 41
string fuctions 4 25
Help Required 3 95
T-SQL: "HAVING CASE" Clause 1 23
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

776 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