--登陆成功返回用户名不存在返回密码错误返回登陆超过次返回试登陆次数超过次返回
--drop proc login
create proc Login
@result int output,
@times int output,
@name varchar(10),
@pwd varchar(10)
as
select @times = uTimes from [user] where uName=@name
if(@times>=3)
begin
set @result = 4
return
end
if exists(select * from [user] where uName=@name)
begin
if exists(select * from [user] where uName=@name and uPwd=@pwd)
begin
set @result = 1
end
else --密码错误返回
begin
set @result = 3
update [user] set uTimes= uTimes+1 where uName=@name
select @times = uTimes from [user] where uName=@name
end
end
else --用户名不存在返回
begin
set @result = 2
end
insert into [user] values(‘admin‘,‘000000‘,0)
update [user] set uTimes=0
select * from [user]
declare @times int,@r int
exec Login @r output,@times output ,‘admin111‘,‘admin‘
print ‘times‘+cast(@times as varchar)
print ‘result‘+ cast(@r as varchar)