Using Stored Procedure returned fields in another Stored Proc or Query

From: BGS (anonymous_at_discussions.microsoft.com)
Date: 06/18/04


Date: Thu, 17 Jun 2004 19:21:19 -0700

Hi all,
I've got a Join All stored proc which returns about
120,000 records.

It simpley returns Account number field and Balance field
for each acustomer ccount for each table.

I want to use the returned data as if it were just
another table or view. As in:

Select * from spGetAllAccountBalances

or Retrieving the customers Credit Limit and linking to
the customers AccountBallance:

SELECT
spGetAllAccountBalances.Acct,
spGetAllAccountBalances.Bal,
Customer.CreditLimit,
FROM
dbo.Customer
INNER JOIN
spGetAllAccountBalances
ON
Customer.Acct = spGetAllAccountBalances.Acct

I just can't get at the stored proc data...

I don't mind doing this thru a stored procedure but would
prefer to use in a view...

Any help would be appreciated,

Thanks
    BGS

-----------------

CREATE PROCEDURE spGetAllAccountBalances
@year as char(4),
@period as char(2)
AS
SELECT
    A.ACCT, A.BAL
FROM
    dbo.A
WHERE CAST(RTRIM(A.FISCYR) + RTRIM(A.FISCPER) AS INT)
<= CAST(@year + @period AS INT)
UNION ALL

SELECT
    B.ACCT, B.BAL
FROM
    dbo.B
WHERE CAST(RTRIM(B.FISCYR) + RTRIM(B.FISCPER) AS INT)
<= CAST(@year + @period AS INT)
UNION ALL
----- Table c,d,e, etc...

GO



Relevant Pages

  • Stored Proc results vs. Query Analyzer
    ... I've got a stored proc that isn't giving the results it ... copy/pasted it into query anlayzer (commenting out only ... as the ones used in the copy/paste of the stored proc ... @src as int, ...
    (microsoft.public.sqlserver.programming)
  • TableAdapter, INNER JOINs, stored procs, and problems with Update
    ... I have a stored procedure that uses JOINs to return columns from multiple ... I also have another stored proc that that takes a series of params ... @ac2 int, ...
    (microsoft.public.dotnet.framework.aspnet)
  • 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)
  • Re: TableAdapter, INNER JOINs, stored procs, and problems with Update
    ... I also have another stored proc that that takes a series of params and updates multiple tables. ... by default a FormView attached to the table adapter did not show Edit/Insert/Delete buttons. ... LEFT OUTER JOIN C c ON a.c1 = c.c1 ... @ac2 int, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Emptying the buffers
    ... However.....is it possible to run the Stored Proc without actually returning the results in query analyser? ... declare @tb table (run int identity primary key, ... >> Will the command 'DBCC DROPCLEANBUFFERS' achieve what I need? ...
    (microsoft.public.sqlserver.programming)