Calling a Stored Procedure from within a Stored Procedure

Calling a Stored Procedure from within a Stored Procedure

Post by SysAnalys » Wed, 05 Mar 2003 07:48:26



Can't seem to locate anything on this topic so I am querying  the group.

Is there any way to perform an SQL SELECT statement from the returned
resultset of a stored procedure?

Example:

Select colA, colD, colH, colJ
from (    Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
order by colA

This doesn't work but you should get the point.

R

 
 
 

Calling a Stored Procedure from within a Stored Procedure

Post by Bob Barro » Wed, 05 Mar 2003 07:56:08



>Can't seem to locate anything on this topic so I am querying  the group.

>Is there any way to perform an SQL SELECT statement from the returned
>resultset of a stored procedure?

>Example:

>Select colA, colD, colH, colJ
>from (    Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
>order by colA

>This doesn't work but you should get the point.

Use OPENQUERY or OPENROWSET (thanks to Tom Moreau)

HTH,
Bob Barrows
Please reply to the newsgroup. My reply-to address is my "spam trap" and I don't check it very often.

 
 
 

Calling a Stored Procedure from within a Stored Procedure

Post by hngo0 » Wed, 05 Mar 2003 07:57:56


Did you try to use a View?
-H
Quote:>-----Original Message-----
>Can't seem to locate anything on this topic so I am

querying  the group.
Quote:

>Is there any way to perform an SQL SELECT statement from
the returned
>resultset of a stored procedure?

>Example:

>Select colA, colD, colH, colJ
>from (    

Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
Quote:>order by colA

>This doesn't work but you should get the point.

>R

>.

 
 
 

Calling a Stored Procedure from within a Stored Procedure

Post by Bob Barro » Wed, 05 Mar 2003 07:58:56



>Can't seem to locate anything on this topic so I am querying  the group.

>Is there any way to perform an SQL SELECT statement from the returned
>resultset of a stored procedure?

>Example:

>Select colA, colD, colH, colJ
>from (    Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
>order by colA

>This doesn't work but you should get the point.

Oops - I was too quick on the Send button.

Here's an example that was provided by Tom Moreau a few posts ago:

create view MyView
as
SELECT
   *
 FROM
   OPENROWSET
   (
     'SQLOLEDB'
   , 'SERVER=(local);Trusted_Connection=yes'
   , 'SET FMTONLY OFF EXEC sp_who2'
   )

HTH,
Bob Barrows
Please reply to the newsgroup. My reply-to address is my "spam trap" and I don't check it very often.

 
 
 

Calling a Stored Procedure from within a Stored Procedure

Post by Bob Barro » Wed, 05 Mar 2003 08:14:03



>Can't seem to locate anything on this topic so I am querying  the group.

>Is there any way to perform an SQL SELECT statement from the returned
>resultset of a stored procedure?

>Example:

>Select colA, colD, colH, colJ
>from (    Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
>order by colA

>This doesn't work but you should get the point.

And more from Erland:
http://www.algonet.se/~sommar/share_data.html

HTH,
Bob Barrows
Please reply to the newsgroup. My reply-to address is my "spam trap" and I don't check it very often.

 
 
 

Calling a Stored Procedure from within a Stored Procedure

Post by SysAnalys » Wed, 05 Mar 2003 16:12:51


Struck gold with our Google search wording and now see this a fairly common
request. Don't know why we didn't find these earlier. Anyway, thanks for all
the feedback. We have set this up already and it works fine.

R



> >Can't seem to locate anything on this topic so I am querying  the group.

> >Is there any way to perform an SQL SELECT statement from the returned
> >resultset of a stored procedure?

> >Example:

> >Select colA, colD, colH, colJ
> >from (    Exec 'SomeExistingStoredProcedure ''SomeParameter'' '   )
> >order by colA

> >This doesn't work but you should get the point.

> And more from Erland:
> http://www.algonet.se/~sommar/share_data.html

> HTH,
> Bob Barrows
> Please reply to the newsgroup. My reply-to address is my "spam trap" and I

don't check it very often.