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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I execute a sp in a select statment 2

Status
Not open for further replies.

mercwrought

Programmer
Dec 2, 2004
176
US
Can you execute a sp in a select statement?

Like…

Code:
select * from ( sp_whatever 3456) as XX
 
I think what you are looking for here is a user defined function (UDF)
 
only a few more month to upgrage to 2003 yea!

ok I found my sultion {CALL sp_whatever (123)}

thx for all of the help
 
I think the closest you can do is

INSERT Table EXEC StoredProc

So at least you could create a temp table with the correct columns and insert the results of the other stored proc, then select * from the temp table.

Every other permutation I've tried fails, that is, the following don't work:

SELECT * FROM EXEC StoredProc
SELECT * FROM (EXEC StoredProc) A

-------------------------------------
Only the unvirtuous can be dutiful, for the virtuous already perform duty's requirements by inclination and for pleasure. Where there is no pain, no disinclination, there is no duty.
- Erik E
 
I found the end run. A long way around but it gets you there...

SELECt *
FROM OPENROWSET('SQLOLEDB','server';'id';'password',
'EXEC database.dbo.sp @parms') AS a
 
hey is... great find... seems silly to have to do it that way.. but that is Microsoft for you... At least now I know it can be done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top