Calling a stored procedure in a SELECT list on SQL Server 2000
0
Q:
Calling a stored procedure in a SELECT list on SQL Server 2000
I am using SQL Server 2000, and my question is: is there any way to call a stored procedure in a SELECT list?
ASKED: Jun 24 2008  8:16 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
15 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
No, stored procedures can not be called as part of a select statement.

You can either create a temp table and load the data from the output of the stored procedure into the temp table, then join to the temp table, or convert the stored procedure into a function which can then be included as part of a select statement.

Not quite true...

It can be done by setting up a linked-server reference and then use OPENQUERY. See books online.

Example: SELECT * FROM OPENQUERY(linked_server name, 'EXEC stored procedure name')
Last Answered: Oct 7 2008  5:43 PM GMT by Rljones39   15 pts.
Latest Contributors: Mrdenny   46795 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Mrdenny   46795 pts.  |   Jun 24 2008  10:24PM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 

Mrdenny   46795 pts.  |   Oct 9 2008  1:53AM GMT

True, it can be done via OPENQUERY, provided that you have open query enabled on your system. By default it is disabled on SQL Server 2005 and up.

 
0