Solved

using SP as a table in a select statement

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
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.

759 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

20 Experts available now in Live!

Get 1:1 Help Now