Hi Everyone,
I am working on the below stored proc that counts total processes and display it through a label on the page.
USE [MyProc]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[AUDITINGHISTORY]
(
@userId BIGINT
)
AS
BEGIN
SET NOCOUNT ON
SELECT TOP 5 A.MobileNo AS 'Mobile No',A.Barcode AS 'Barcode',
CONVERT(NVARCHAR(50),A.CreatedOn,120) AS 'Audit Time'
FROM AuditFlagsView A WHERE A.CreatedBy=@userId ORDER BY A.CreatedOn DESC
DECLARE @Login NVARCHAR(50),@Logout NVARCHAR(50),@totalcnt BIGINT,@TempTime DATETIME
CREATE TABLE #Temp
(
rowId bigint identity,
Logintime DATETIME
)
INSERT INTO #Temp select TOP 2 LoginTime from UserLoginView WHERE Uid=@userId AND Logintype='Login' order by LoginTime DESC
select @Login=convert(nvarchar(50),Logintime,100) from #Temp where rowid=1
select @Logout=convert(nvarchar(50),Logintime,100) from #Temp where rowid=2
select @totalcnt=count(AuditId) from AuditFlagsView where CreatedBy=@userId AND
CONVERT(NVARCHAR(50),CreatedOn,103)=CONVERT(NVARCHAR(50),getdate(),103)
SELECT @Login as 'LogIn', @Logout as 'LogOut',@totalcnt as 'TotalCnt'
END
--------------------
The procedure is working, but whenever I log on to a page, it shows Total Processed count as "1" instead of "0". I think I need to use the date function for this. Can anyone please suggest anything?