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!

a SELECT statement using exec

Status
Not open for further replies.

stiej

Technical User
Jan 20, 2003
142
GB
Hi,

Is it possible to execute another procedure in the "from" bit of a select statement as in:

select id from exec anothersp

to benefit clarity, anothersp would normally return, say, id, name, age or whatever.

Any help much appreciated!

Thanks.
 
The object after the FROM clause needs to be a table or view.

Thanks

J. Kusch
 
You could fill a temp table with the results of the sp and then select from that...

dlc
 
okay, thanks guys. did think of the temp table thing, but thought it'd be more nice and "inline" if you could get the results directly from exec another procedure there and then. Thanks though!
 
If you are using sql2k - you could employ a user defined function that returns a table
 
that sounds interesting? Can you exapnd?
 
stiej,
Just look up 'SQL User-Defined Functions' in books on line.

The bottom line is that you can create a function whose return value is a table - and you can use that return value just as if it were a table or view as in select * from dbo.myUdf(parm).

There were many, many improvements from version 7 to 2k, but I have to admit that user defined functions are my favorite.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top