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)
 Re: Calling stored procedure from another stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-14 : 10:50:02
DeLeon writes "I did have a question for you. I wanted to know how do you call a stored proc from another stored proc? I have several stored proc that perform functions I'd like to reuse. I particular, I'd like to know how do I call a stored proc that returns both a recordset or single row from another stored procedure. This would be on the same machine in the same database. Also, how to I use the parameters or recordsets in the caller to execute more sql statement.

I've looked quite a few places and have come up empty on how to accomplish this.

Your help would be greatly appreciated."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-14 : 11:18:35

create proc examplea
@outparm int out
as
set @outparm = 1
go

create proc exampleb
as
select 'Hullo, mommie'
union
select 'its page'
go

create proc examplec
as
declare @exampleaoutput int
create table #exampleboutput (
examplebcol varchar(20) )

exec examplea @outparm = @exampleaoutput out
select @exampleaoutput

insert #exampleboutput
exec exampleb

select * from #exampleboutput
go

exec examplec


<O>
Go to Top of Page
   

- Advertisement -