-1

我有这个存储过程:

CREATE PROCEDURE [dbo].[getCorrespondingRespcode]
@rc char(3)
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @webRcCount int

    SELECT webRc, COUNT(*) as webRcCount  
    FROM payterm.response_codes_mapping  
    WHERE rc = @rc GROUP BY webRc
END

如何设置@webRcCount的值webRcCount?我需要去做if @webRcCount = 1 print'ok'

4

2 回答 2

2
SELECT @webRcCount = COUNT(*) 
FROM payterm.response_codes_mapping 
WHERE rc = @rc

SELECT @webRcCount AS [WebRCCount]

应该这样做...

于 2013-05-14T14:57:11.633 回答
0

您的意思是计算表中的不同 webRc值吗?如果是这样,请改用它:

SELECT @webRcCount = COUNT(DISTINCT webRC) 
FROM payterm.response_codes_mapping 
WHERE rc = @rc;
于 2013-05-17T05:30:11.783 回答