TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Micah David
NA
25
9k
How do i login with Email and select records with UserName
Aug 12 2016 8:22 AM
here is code for login, but am not sure if i got it right, also how do i fetch record using username after login with email
ALTER
PROCEDURE
[dbo].[Validate_User]
@Id
int
,
@UserName NVARCHAR(200),
@Email NVARCHAR(200),
@
Password
NVARCHAR(20)
AS
BEGIN
SET
NOCOUNT
ON
;
DECLARE
@UserId
INT
, @LastLoginDate DATETIME
SELECT
@UserId = UserId, @LastLoginDate = LastLogin
FROM
User3
WHERE
UserName = @Email
AND
[
Password
] = @
PassWord
IF @UserId
IS
NOT
NULL
BEGIN
IF
NOT
EXISTS(
SELECT
UserId
FROM
UserActivation
WHERE
UserId = @UserId)
BEGIN
UPDATE
User3
SET
LastLogin = GETDATE()
WHERE
UserId = @UserId
SELECT
@UserId [UserId]
-- User Valid
END
ELSE
BEGIN
SELECT
-2
-- User not activated.
END
END
ELSE
BEGIN
SELECT
-1
-- User invalid.
END
END
Reply
Answers (
1
)
Exact use of Table variable and Temp table
Split function in store procedure