从存储过程中返回最后一个结果集

时间:2019-10-11 07:00:03

标签: sql sql-server

存储过程a正在调用另一个过程b,而b具有两个out参数以及一个带有select语句的结果集。现在,我想使用select语句从a返回结果集,但是当我执行a时,它将显示两个结果集,首先是b,然后是a

那么如何获取仅a的结果集?请不要将b的结果存储到临时表中。谢谢。

a usp_Save_IssuancePcsStToSt 
b usp_Stitcher_Stock_Form

b的细节

    @st_code smallint, 
    @QltyCode varchar(30),
    @ColorCode varchar(6),
    @NetPieces int = NULL out ,
    @NetWeight numeric(13,4) = NULL out
)
AS
BEGIN

    DECLARE @rowNum int= 0;

    SELECT 
        @rowNum = ROW_NUMBER() OVER (ORDER BY st_code, quality_code, o_color_code), 
        @NetPieces = ISNULL(SUM((rec_pcs + adj_plus_pcs + reopen_pcs)- (issued_pcs + adj_minus_pcs + re_packing_pcs+ return_pcs)), 0),
        @NetWeight = ISNULL(SUM((rec_wt + adj_plus_wt + reopen_wt) - (issued_wt + adj_minus_wt + return_wt + re_packing_wt)), 0.00)
    FROM 
        dbo.v_rpt_cc_transaction_all 
    WHERE 
        doc_date >= '03/02/2014' 
        AND st_code = @st_code
        AND quality_code = @QltyCode
        AND o_color_code = @ColorCode
    GROUP BY 
        st_code, quality_code, o_color_code

    SELECT @rowNum AS SerialNumber, ISNULL(@NetPieces, 0) AS net_pcs , ISNULL(@NetWeight, 0.00) AS net_wt

0 个答案:

没有答案