Thursday, February 4, 2010

HOW TO USE VARIABLES IN PROC

ALTER PROCEDURE [dbo].[360LMS_LogOutUser]
(
@UserID int
)
AS
declare @logid int
declare @Ttime int
declare @intime Datetime
set @logid=(Select Max(LogID) from [360LMS_UserLogs] where UserID=@UserID)

set @intime=(Select LoginDateTime from [360LMS_UserLogs] where UserID=@UserID and LogID=@logid)
set @Ttime=(Select Max(TotalTime) from [360LMS_UserLogs] where UserID=@UserID)

set @Ttime=(@Ttime + DATEDIFF(minute, @intime, getdate()))

Update [360LMS_UserLogs] set LogoutDateTime =getdate(),SessionTime=DATEDIFF(minute, @intime, getdate()) ,
TotalTime=@Ttime
where UserID=@UserID and
LogID=@logid;
UPDATE [360LMS_Users] SET LoginFlag='False' where UserID=@UserID
Update [360LMS_tblChatMassages] set IsOnline='False' where UserID=@UserID

No comments:

Post a Comment