0
我有一個存儲過程需要兩個參數:開始日期(@SDate
)和結束日期(@EDate
),之後它輸出兩個日期之間的數據摘要。SSMS存儲過程不顯示記錄在結束日期
但是,它不顯示落在@EDate
上的記錄。
這是我的代碼:
DECLARE TidCursor SCROLL CURSOR
FOR
SELECT DISTINCT
A.TID, P.ProjGroup, A.Location, P.MainSubCon
FROM
[PRT].[dbo].[Personnel] P,[PRT].[dbo].[Attendance] A
WHERE
A.TID = P.TID
AND (A.Timein BETWEEN @SDate AND @EDate)
AND (A.Timeout BETWEEN @SDate AND @EDate)
AND (A.Timein IS NOT NULL AND A.timeout IS NOT NULL)
ORDER BY
A.TID ASC
OPEN TidCursor
FETCH NEXT FROM TidCursor INTO @rec1_Tid, @rec1_PG, @rec1_Loc, @rec1_MainSubCon
.
.
.
DECLARE AttnCursor SCROLL CURSOR FOR
SELECT TimeIn, TimeOut, Location
FROM Attendance
WHERE TID = @rec1_Tid
AND (Timein BETWEEN @SDate AND @EDate)
AND (Timeout BETWEEN @SDate AND @EDate)
AND (Timein IS NOT NULL AND timeout IS NOT NULL)
ORDER BY TimeIn
-- variables used to check for multiple logins in the same day
SET @curDate = '';
SET @preDate = '';
OPEN AttnCursor
FETCH NEXT FROM AttnCursor INTO @indt, @outdt, @inloc
WHILE (@@FETCH_STATUS = 0)
BEGIN
.
.
.
FETCH NEXT FROM AttnCursor INTO @indt, @outdt, @inloc
END -- END WHILE (@@FETCH_STATUS = 0)
-- Closes the cursor
CLOSE AttnCursor;
DEALLOCATE AttnCursor;
FETCH NEXT FROM TidCursor INTO @rec1_Tid, @rec1_PG, @rec1_Loc, @rec1_MainSubCon
END -- END WHILE (@@FETCH_STATUS = 0)
-- Closes the cursor
CLOSE TidCursor;
DEALLOCATE TidCursor;
啊啊啊,爲什麼我現在明白了。謝謝! – Junxian