Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a stored procedures as part of a select statement 1

Status
Not open for further replies.

LokiDba

Programmer
Dec 13, 2000
63
GB
Hi,

I have a stored procedure that is used through-out my
database, but I need to use its resultset as part of a
query to generate an upload table. Is there any way I can
use this result set as part of a SELECT statement.

For Example

SELECT Name
FROM sp_Help

Any one got any ideas?

Thanks in Advance

LokiDBA
 
I know you can insert data from a sp into another table
e.g. insert tblData exec sp_help

Will this help ? If there's not much data and you need to manipulate it a bit, you could put it into a temporary table.
 
Stored procedures cannot be used in a select statement. As moonshadow said, you can INSERT the results of a stored procedure into a tamporary table and then select from the table.

In SQL 2000, another option is available. You can create a function that returns a table. You can select from the function just as you would from a table. See SQL BOL for details and syntax. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Thanks very much.

I've gone for the insert into temp table


LokiDBA
 
So how come I don't get a star ?
(Admittedly I was only repeating something Terry said last week).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top