我有这个存储过程:
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'
答案 0 :(得分:2)
SELECT @webRcCount = COUNT(*)
FROM payterm.response_codes_mapping
WHERE rc = @rc
SELECT @webRcCount AS [WebRCCount]
应该这样做......
答案 1 :(得分:0)
您是否要在表格中计算不同的 webRc
值?如果是这样,请改用:
SELECT @webRcCount = COUNT(DISTINCT webRC)
FROM payterm.response_codes_mapping
WHERE rc = @rc;