My intention is to store the user's last login date and time when he logs in to the web page. I pass his username and password to the stored procedure to check whether is it correct or not! I believe it'll be fine to store his last login date and time if any record matches.
USE [DBNAME] GO /****** Object: StoredProcedure [dbo].[WP_LogInUser] Script Date: 27-Apr-15 4:09:38 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[WP_LogInUser] @Username Nvarchar(100), @Password Nvarchar(100) as Begin if exists(Select Username from TableName where Username=@Username and UserPassword=@Password) Begin Update TableName Set UserLastLogin = GETUTCDATE() where Username=@Username and UserPassword=@Password and IsActive = 1 Select UserID, Username, UserEmail, UserFullName, UserType from TableName where Username=@Username and UserPassword=@Password and IsActive = 1 End End
What do you think about it? Is it okay? Or can I make this even better?