Re: resultset of proc in another proc



helmut woess wrote:
Hello,

i want to use the result set from a stored proc in another stored proc, for
example:

create stored procedure proc1 (@x int) as
declare @tbl (y1 int, y2 int)
insert into @tbl values(@ * @x, @x * @x * @x)
select * from @tbl
GO
--
create stored procedure proc2 (@x int) as
declare @tbl (y1 int, y2 int)
while @x > 0 begin
  insert into @tbl select (exec proc1 @x)  <-- this is my problem
  set @x = @x - 1
end
select * from @tbl
GO
--

I know i could use output parameters. But i want to know if something is
possible with SQL-Server?

thanks,
Helmut

This is a good summary of the options:

http://www.sommarskog.se/share_data.html

Simon
.



Relevant Pages

  • Re: Calling Stored Proc from a Function
    ... DECLARE @rc AS INT, @seqid AS INT; ... UPDATE sequences ... > need to do an update statement, I have to use a stored proc as you can ...
    (microsoft.public.sqlserver.programming)
  • Accessing value from dynamic SQL
    ... I need to access the value of dynamic SQL statement within a stored proc. ... DECLARE @z int ... DECLARE @t varchar ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL StoredProc Help
    ... if i have understand you need to pass a xml stream to your stored proc ?! ... @USER_ID int, ... Declare @CORP_PRODUCT_COUNT int ...
    (microsoft.public.sqlserver.xml)
  • Stored Proc date range not producing a RS
    ... When I run the following Stored Proc in SQL Analyzer, ... DECLARE @StartMonth int ... DECLARE @StartDate varchar ...
    (microsoft.public.sqlserver.programming)
  • Re: recordset from a temp table /ty (resolved)
    ... i tried putting SET NOCOUNT ON before the stored proc ( ... Declare @EndTo int ...
    (microsoft.public.sqlserver.programming)