plz help
How to write mulitiple queries in storedprocedure?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raj KumarPosted Jul 21, 2008, 12:40 AM
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
CREATE PROCEDURE [dbo].[ValidateUserLogin]
(
@Email varchar(300),
@PWD varchar(100),
@IPAddress varchar (20) = '',
@ReturnValue int out
)
AS
if exists(SELECT [Name] FROM Users WHERE Email = @Email AND Password = @PWD AND IsActive=1 )
Begin
UPDATE Users SET LastLogin = GetDate(), IPAddress = @IPAddress WHERE UserID = @UserID AND Password = @PWD
UPDATE [Security] SET IPAddress = @IPAddress WHERE EMailAddress = @Email
SELECT * FROM users WHERE Email = @Email AND Password = @PWD
End
if(@@Error<> 0)
BEGIN
RAISERROR ('Error in SP [ValidateUserLogin], Unable to Validate/Update the record.', 16,1)
Return
END
else
Set @ReturnValue = 0