--登陆成功返回用户名不存在返回密码错误返回登陆超过次返回试登陆次数超过次返回
--drop proc login
createprocLogin
@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
insertinto [user] values(‘admin‘,‘000000‘,0)
update [user] set uTimes=0
select * from [user]
declare @times int,@rint
execLogin @routput,@timesoutput ,‘admin111‘,‘admin‘
print ‘times‘+cast(@times asvarchar)
print ‘result‘+ cast(@r asvarchar)