Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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