Solved

SELECT SELECT SQL Query Result

Posted on 2007-12-05
6
320 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now