Sunday, March 11, 2012

calling a stored procedure from another

Hi All,

could anyone help me with an example as to how to call a stored procedure from another procedure.

I need to call sprocA, which inserts values in DB and also retuns an integer value, pass this integer value to sprocB and perform some inserts.

Thanks in advance,

vnswathi.

This calls one procedure and users an output value for input to the other, if the first succeded

declare @.retvalue int;
declare @.outputvalue int;

execute @.retvalue = sprocA @.outputvalue output;

if @.retvalue = 0
begin
execute @.retvalue = sprocB @.outputvalue;
end

EDIT: I just saw now that this was in reporting services so not sure if this will help as it is just how to do it in TSQL

No comments:

Post a Comment