• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

using SP as a table in a select statement

How can i use stored procedure in a select statement as a table
0
amnav
Asked:
amnav
2 Solutions
 
ColinSnellingCommented:
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
 
Mr_PeerapolCommented:
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
 
David ToddSenior DBACommented:
Hi,

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

Regards
  David
0
 
CleanupPingCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now