Executing a Stored Procedure in a Stored Procedure and selecting on the result

Executing a Stored Procedure in a Stored Procedure and selecting on the result

Post by Ole Bore j » Tue, 30 Apr 2002 00:25:22



Hi

Is there any way available to select on the result of a sp in another sp?

Example:
Alter Procedure sp_Sp2

As

Select *
From EXEC sp_Sp1

How can I do this?

Ole

 
 
 

Executing a Stored Procedure in a Stored Procedure and selecting on the result

Post by BP Margoli » Tue, 30 Apr 2002 01:43:14


Ole,

Please ALWAYS post which version of SQL Server you are using.

You can do this via the OPENROWSET or OPENQUERY options of the SELECT
command.

Check out the documentation on OPENROWSET and OPENQUERY in the SQL Server
Books Online.

If you are using SQL Server 2000, it will probably make more sense to
convert the stored procedure to a user-defined function. Documentation on
user-defined functions can be found in the SQL Server 2000 Books Online.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.



> Hi

> Is there any way available to select on the result of a sp in another sp?

> Example:
> Alter Procedure sp_Sp2


> As

> Select *
> From EXEC sp_Sp1

> How can I do this?

> Ole


 
 
 

Executing a Stored Procedure in a Stored Procedure and selecting on the result

Post by Ole Bore j » Wed, 01 May 2002 01:14:14


BP

I'm sorry I  didn't post my sql-server version. It is 7.0.

I accomplished this by creating a temporary table, insert the results
from sp into that one, and by this I could manipulate the results.

Thank you for your tip

Ole


> Ole,

> Please ALWAYS post which version of SQL Server you are using.

> You can do this via the OPENROWSET or OPENQUERY options of the SELECT
> command.

> Check out the documentation on OPENROWSET and OPENQUERY in the SQL Server
> Books Online.

> If you are using SQL Server 2000, it will probably make more sense to
> convert the stored procedure to a user-defined function. Documentation on
> user-defined functions can be found in the SQL Server 2000 Books Online.

> -------------------------------------------
> BP Margolin
> Please reply only to the newsgroups.
> When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
> can be cut and pasted into Query Analyzer is appreciated.



> > Hi

> > Is there any way available to select on the result of a sp in another sp?

> > Example:
> > Alter Procedure sp_Sp2


> > As

> > Select *
> > From EXEC sp_Sp1

> > How can I do this?

> > Ole

 
 
 

1. using SQL stored procedure results in stored procedure

OK, here's a trick question I would love an answer to.

I want to use the result table generated by a stored procedure
in the stored procedure which called it.

It is possible to retrieve the result table created by a stored procedure,
if you use some external library (DB-Lib, ODBC, etc.); is it
possible to do from with in a stored procedure?

The specific example I am trying is:

- Have multiple transaction log dumps to a single dump file
- The transaction logs in the dump file are serialized (1,2,3...)
- I can use LOAD HEADERONLY FROM <dumpfile> to retrieve a table
  listing the details (include the index numbers) in the output
  screen (or from an external client), but I can't reference the output
  from sql code.

There are other ways around this problem (which I have taken, which
are real *hacks*), but this is a common problem I run into: the info
I need I can get from a stored procedure, but I can't *use* the info
once I have it.

Any suggestions will be appricated.

2. External search engine, advice

3. Using Stored Procedure's results in a Stored Procedure

4. SQL parsing efficiency

5. executing system stored procedures within a stored procedure

6. SAS table statement documentation

7. Using the result from one stored procedure in a second stored procedure

8. New records in the datagrid is not visible

9. Passing a result set from one stored procedure to another stored procedure

10. Using Results Of Stored Procedure As Input Into Another Stored Procedure

11. Returning a query result from a stored procedure into another stored procedure

12. Retrieving result from a stored procedure called within another stored procedure

13. Executing stored procedure from another stored procedure.