Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calling stored procedures (that return mutiple rows of data) from within stored procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-07-06 : 11:55:21
Kerrie writes "I've created a complex stored procedure that results in the return of a (@local) table. How can I reference that stored procedure in another and capture the data in a cursor?

For example, I want to create a proc that evalutes data returned from the sys proc, sp_helpuser. How do I capture the data from within my stored procedure (using TRANSACT-SQL statements) so I can evalute it?

Is there a way to use the EXEC statement and manage the results in a cursor?

A little lost... thanks for your help."

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-06 : 12:23:15
Well your general question would be...


Create Table #myTable (definition)

Insert Into #myTable
Exec db.owner.proc @blah...

Columns in temptable must match output columns...


how to use with sp_helpuser and such... anyone? anyone?

Corey
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-07-06 : 19:06:26
It's not pretty, but I posted a solution to get results from sp's that return multiple result sets a while back;

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37008&SearchTerms=sp_helplogins[/url]

It also shows how to get results from procedures without knowing column names/types.
Go to Top of Page
   

- Advertisement -