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

Access results from nested stored procedure

Status
Not open for further replies.

Brit

Programmer
May 15, 2001
15
US
Is there any way to access the recordset from an existing sp called in another sp. For instance:
declare @user varchar(100),
@pswd varchar(15)
declare @crsr cursor
set @crsr = cursor for exec ext_storedproc
open @crsr
fetch next from @crsr
into @user, @pswd
While (@@fetch_status = 0)
BEGIN
select 'record:', @user, @pswd
End
close @crsr
deallocate @crsr

I know I can use a select statement instead of executing an existing stored procedure but then I have to maintain the code in two places.
 

You can insert the result set from a stored procedure into a table. Then select from that table.

Create Table #tmp (user varchar(100), pswd varchar(15))
Insert #tmp
Exec ext_storedproc


Declare @crsr cursor
Set @crsr = cursor for
Select * From #tmp
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top