如何在SQL Server中从另一个调用一个存储过程

如何在SQL Server中从另一个调用一个存储过程

问题描述:

如何从另一个存储过程中调用一个存储过程以及何时执行该操作。则它不会在Crystal Report字段资源管理器中更新。

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.

这是我的代码:

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,

我需要帮助,我用Google搜索了很多,但没有任何解决方法

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

预先感谢...

您可以使用 EXEC 命令。但是,使用SQL Server用户定义函数可能会更好。

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

请参阅: https://technet.microsoft.com/zh-cn/library/aa175085(v = sql.80).aspx