Thursday, March 22, 2012

Calling nested stored proedure many times

There are two stored procedures. One calls the other one time. It works.
create procedure nestedSP
@.p float
as
declare @.q float
set @.q = @.p
select @.q
go
create procedure CallingNestedSP
@.p float
as
exec nestedSP @.p
go
exec CallingNestedSP 111.11
How do I get the resultset as 111.11, 111.11 by calling the nexted twice.
Please advise. Thanks
PeterHi Peter
There is no best way of joining the two results from SPs ...
You can maybe try to create the called procedure as a UDF and
call it twice.Or if you only have to use a SP,
then insert the result into a temp table. Your calling SP will have the code
like this..
create procedure CallingNestedSP
@.p float
as
begin
create table #temp (a decimal(...))
INsert into #temp
exec nestedSP @.p
select a,a from #temp
end..
Though I would prefer a udf for a situation similar to yours.
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/

No comments:

Post a Comment