April 29, 2009 at 1:15 am
Hi i have two stored procedures of which the first one calls the other with in it (sproc1 + sproc2)
sproc2 returns a recordset containing two columns of one record long. Is there a way to catch the output of the recordset in sproc1 and place them in output parameters without needing to convert sproc one to return the recordset as output parameters.
My current procedure when executed outputs the recordset but i would like to stop this from happening and place the recordset into output parameters
Thanks
ALTER PROCEDURE sproc1
AS
begin
-- Sproc2 returns recordset
exec sproc2
end
April 29, 2009 at 5:44 am
In this article you'll find methods hos to share data between procedures:
April 29, 2009 at 7:00 am
You can use temporary table into SP-1.
in sp-1
create table #temptbl (col1 dt1, col2 dt2)
insert into #temptbl exec sp2
......................
drop table #temptbl
"Don't limit your challenges, challenge your limits"
April 29, 2009 at 7:57 am
.... and a novel thought...
Why not just have the nested proc return those two values as output parameters itself, rather than as a two-column, one-row result set? Calling procedure catches the output values into it's own output parameters. Problem solved.
However, if you MUST leave the nested procedure as is, you can catch the output values of the two column result set by doing the following. BUT performance will be much slower than just catching output parameters from proc2 and passing them on.
declare @catch table (col1 varchar(50), col2 varchar(50)) --<< use same datatypes as proc2 will return
--
insert into @catch
exec proc2
--
select @outparm1 = col1, @outparm2 = col2 from @catch
--
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
April 30, 2009 at 10:40 pm
Bob, i just wanted to say what you said... 🙂
the difference is, i used temporary table and you used table variable.... 😀
"Don't limit your challenges, challenge your limits"
May 1, 2009 at 7:51 am
Sorry to be redundant, kruti 🙂
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
May 1, 2009 at 12:19 pm
I agree that output parameter would be the lean way to go.
I've always used temp tables to return a recordset in those cases, must be an old habit as table variables didn't used to work as I remember, but I just tried an and it works, so I guess that I was just stuck in the past.
May 1, 2009 at 10:41 pm
Bob, no need to be sorry!!! 🙂
It happens... 😎
"Don't limit your challenges, challenge your limits"
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply