更改用户密码的存储过程及测试
create procedure Admin_UpdatePassWord
@userName varchar(50), @oldPwd varchar(50), @newPwd varchar(50), @isUpdated int=0 output
as
select @oldPwd=[password] from AdminReg where username=@userName
if(@oldPwd is not null)
begin
update AdminReg set [password]=@newPwd where username=@userName
select @isUpdated = 1
end
else
begin
select @isUpdated = 0
end
declare @retVal int
exec Admin_UpdatePassWord @userName='ayuan', @oldPwd='ayuan', @newPwd='123', @isUpdated=@retVal output
print @retVal
select * from AdminReg
declare @newPwd varchar(50), @userName varchar(50)
set @newPwd='123'set @userName='ayuan'
update AdminReg set password=@newPwd where [UserName]=@userName
print @userName
Select username, aid from AdminReg where password='ayuan'