Re: Using Stored Procedure returned fields in another Stored Proc or Query

From: Hari (hari_prasad_k_at_hotmail.com)
Date: 06/18/04


Date: Fri, 18 Jun 2004 14:42:22 +0530

Hi,

Have a look into Inline table valued User defined functions in books online

--
Thanks
Hari
MCDBA
"BGS" <anonymous@discussions.microsoft.com> wrote in message
news:1e13a01c454da$f0d96800$a501280a@phx.gbl...
> 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
>