Solved

using SP as a table in a select statement

Posted on 2002-05-20
5
254 Views
Last Modified: 2006-11-17
How can i use stored procedure in a select statement as a table
0
Comment
Question by:amnav
[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
5 Comments
 
LVL 1

Expert Comment

by:ColinSnelling
ID: 7021126
To the best of my knowledge this is not possible.  I really wish it was as there are a number of occasions where I'd use it myself.

I think that the only thing you can do it put the results of the SP into a temporary table and use that in your SELECT query.

INSERT INTO #myTable exec sp_GetMyResults

Colin
0
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 48 total points
ID: 7021247
If you are using MS SQL Server 2000, try converting your stored procedure to user-defined function. Then you will be able to use it in a select statement.

Ex. select * from fn_YourFunction(0, 'Hello')

Or else you need to do like the comment above from ColinSnelling.

Hope it helps,
C
0
 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 48 total points
ID: 7028788
Hi,

The other suggestion is to use the stored procedure to return the record set by passing parameters to it.

Regards
  David
0
 

Expert Comment

by:CleanupPing
ID: 9280477
amnav:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

628 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