How to call one stored procedure from another in S

2019-08-11 07:34发布

How to call one stored procedure from another stored procedure and when I do that. Then it is not updating in Crystal Report field explorer.

This is my code:

SP1

ALTER PROCEDURE [dbo].[GetSpecialJournalInfoByJVID]
    (@JvID numeric,@BusinessID numeric)
AS
BEGIN
    SET NOCOUNT ON;

    SELECT * 
    FROM JV 
    WHERE jvID = @JvID AND BusinessID = @BusinessID
END

SP2

ALTER PROCEDURE [dbo].[USP_GetSpecificAccountLedger]
    @JvID                           numeric(18,0),
    -- Add the parameters for the stored procedure here
    @ParamDate1                     datetime,
    @ParamDate2                     datetime,
    @ParamBusinessID                numeric(18,0),  
    @ParamAccountID                 numeric(18,0),
    @ParamCurrentCurrencyRate       decimal(18,10) =1
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT * 
    FROM JV 
    WHERE jvID = @JvID

    -- Insert statements for procedure here
    SELECT 
        COA.ACCOUNTID, COA.ACCOUNTNAME, COA.GLCODE,
        COA.DESCRIPTION AS ACCOUNTDESCRIPTION,
        COA.ISBANKACCOUNT, COA.BANKACCOUNTNO,
        COA.REFACCOUNT, FIXED,
        ISNULL(OPBAL.OPENINGBALANCE, 0) OPENINGBALANCE,
        ISNULL(CURBAL.DR_CUR_BAL, 0) DR_CUR_BAL,
        ISNULL(CURBAL.CR_CUR_BAL, 0) CR_CUR_BAL,
        J.TRNDATE, J.TRNDESCRIPTION, TRNTYPE,

I need help, I googled it a lot but didn't got any solution

thanks in advance...

1条回答
霸刀☆藐视天下
2楼-- · 2019-08-11 07:43

You can call a stored procedure by using the EXEC command. However, it might be better to use SQL Server user-defined function.

Please see: https://technet.microsoft.com/en-us/library/aa175085(v=sql.80).aspx

查看更多
登录 后发表回答