我在我的应用程序中使用此存储过程来获取记录但是没有使用此SP.Give消息从数据库获取记录没有找到记录
CREATE PROCEDURE [dbo].[Proc_RptDailySummaryPTCLBillsCollection_Result]
(
@DateFrom DATETIME,
@DatTo DATETIME,
@SubOfficeID VARCHAR(200),
@GroupId INT,
@ClerkName VARCHAR(200),
@Type VARCHAR(200)
)
AS BEGIN
DECLARE @AgencyTable TABLE (
GpoId INT
, OfcId INT
, Total_Bills BIGINT
, Total_Amount BIGINT
) --Bill_Value BIGINT, Commission BIGINT,
--SET @DatTo = convert(datetime, convert(Varchar(12), @DatTo, 109) + ' 23:59:59PM')
-- Billing Summary By GPO Name
INSERT @AgencyTable (GpoId, OfcId, Total_Bills, Total_Amount) --Bill_Value, Commission,
SELECT
Bil.GroupId
, Bil.SubOfficeId
, ISNULL(COUNT(Bil.ConsumerNumber), 0) --AS Total_Bills,
-- ,ISNULL(SUM(Bil.C_Amount),0) --AS Bill_Value,
--,ISNULL(SUM(Bil.Commission),0) --AS Commission,
, ISNULL(SUM(Bil.C_Amount), 0) - ISNULL(SUM(Bil.Commission), 0) --AS Total_Amount
FROM BillTxnSO AS Bil
INNER JOIN pp_offices ofc ON Bil.GroupId = ofc.Group_Id AND Bil.SubOfficeId = ofc.OfficeCode
WHERE Bil.GroupId = @GroupId
AND TransDate BETWEEN @DateFrom AND @DatTo
GROUP BY Bil.GroupId, Bil.SubOfficeId
--select * from @AgencyTable
SELECT
ofc.OfficeName AS SubOffice
, ofc.Group_ID AS GroupID
, ISNULL(gpo.Total_Bills, 0) AS NoOfBills
, ISNULL(gpo.Total_Amount, 0) AS Amount -- isnull(gpo.Bill_Value,0)as Bill_Value , isnull(gpo.Commission,0) as Commission,
FROM @AgencyTable gpo
INNER JOIN pp_offices ofc ON ofc.Group_ID = gpo.GpoId AND gpo.OfcId = ofc.OfficeCode
ORDER BY ofc.OfficeName
END
答案 0 :(得分:0)
"发出没有找到记录的消息"
使用@@ ROWCOUNT
IF(@@ROWCOUNT = 0)BEGIN
Select 'No record found'
return
END