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 2008 Forums
 Transact-SQL (2008)
 Calling a stored proc inside another stored proc

Author  Topic 

shantanu88d
Starting Member

35 Posts

Posted - 2011-04-13 : 03:04:42
Hi,
I have a stored procedure which is gonna call another stored proc. But I need to get multiple values from it within the calling stored proc. How can I achieve this. The structure is going to be as follows.

Main_Proc(arg1,arg2)
BEGIN
sub_proc(arg1)
--after this I should get values from sum_proc. How????
END


Please help !!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-04-13 : 03:09:44
to call a stored procedure use "exec sub_proc"
use OUTPUT parameter to return value from a stored procedure

create procedure sub_proc
@para1 int,
@para2 int,
@para3 int OUTPUT,
@para4 int OUTPUT
as
begin
select @para3 = @para1 + @para2,
@para4 = @para1 * @para2
end

go
create procedure main_proc
as
begin
declare @para3 int,
@para4 int

exec sub_proc @para1 = 2, @para2 = 3, @para3 = @para3 OUTPUT, @para4 = @para4 OUTPUT

select @para3, @para4
end




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

shantanu88d
Starting Member

35 Posts

Posted - 2011-04-13 : 06:28:22
Hey, Thank you so much !! That really helped. I just did not know how to accpet values from OUTPUT parameters in the calling procedure
Go to Top of Page
   

- Advertisement -