Wednesday, August 3, 2011

PROCEDURE TO CHANGE PASSWORD

/****** Object: StoredProcedure [TestingSP].[prc_User_UPDATE_Password_ByID] Script Date: 08/03/2011 17:39:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*Created By : Sushil Rout
* Created Date : 03 August 2011
* Purpose : Change Password
*/
ALTER PROCEDURE [TestingSP].[prc_User_UPDATE_Password_ByID]
@intClientID INT,
@inbUserID BIGINT,
@chvOldPassword AS VARCHAR (128),
@chvNewPassword AS VARCHAR (128),
@bitUserExists BIT OUTPUT
AS
DECLARE @chvExistingPassword varchar(128)
BEGIN
SET NOCOUNT ON;

SET @bitEndUserExists = 0;

IF @inbEndUserID IS NOT NULL

SELECT @chvExistingPassword = eup.EupPwd FROM dbo.UserPwd eup
WHERE eup.EuID IN (SELECT eu.EuID FROM dbo.Users eu WHERE eu.ClID = @intClientID AND eup.EuID = @inbUserID);

IF @chvExistingPassword = @chvOldPassword

BEGIN

UPDATE dbo.UserPwd
SET EupPwd = @chvNewPassword
WHERE EuID = @inbUserID
SET @bitUserExists = 1;
RETURN 1;
END
ELSE
BEGIN
SET @bitUserExists = -1;
END
END

1 comment:

Anuj Rathi said...
This comment has been removed by a blog administrator.