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
 Old Forums
 CLOSED - General SQL Server
 SP within SP

Author  Topic 

yossibaram
Yak Posting Veteran

82 Posts

Posted - 2002-08-13 : 09:08:00
Hi,
I would like to call SP(1) within SP(2).
SP(1) returns a parameter and I would like SP(2) to send this Parameter to SP(3).
Its sounds complicated but guess its not.
I'm green with Stored procedures and if you know of a link with good examples write it down.
Thanks
Yossi

nr
SQLTeam MVY

12543 Posts

Posted - 2002-08-13 : 09:12:49
create procedure sp2
as
declare @i int, @rc int
exec @rc = sp1 @i output
if @@eror <> 0 or @rc <> 0
return
exec sp3 @i
go

create procedure sp1
@i int output
as
...
select @i = ...
go

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Edited by - nr on 08/13/2002 09:13:12
Go to Top of Page

yossibaram
Yak Posting Veteran

82 Posts

Posted - 2002-08-13 : 10:18:12
nr,
Thanks a lot for the quick reply.
I need SP(1) only to send a parameter without getting any (can i?).
Thanks again
Yossi

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-08-13 : 10:22:47
Output parameters are always input also but the sp doesn't have to use the input.

There is a return code but that is usually used for error codes only and is restricted to an int.

If you don't want the sp to have a parameter at all then you will have to add an entry to a table keyed on the spid for the calling SP to retrieve. SP parameters are much simpler.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -