SELECT SELECT SQL Query Result

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.
mycachaAsked:
Who is Participating?
 
imitchieConnect With a Mentor Commented:
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
 
imitchieCommented:
If this is a stored procedure then you cannot access the result table
0
 
imitchieCommented:
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
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
mycachaAuthor Commented:
Good idea!
can explain detail on how to convert the result set to table?
0
 
mycachaAuthor Commented:
Yea, thats the keyword. INNERTABLE. Thanks yea,
0
 
mycachaAuthor Commented:
Excellent!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.