写的一个验证登陆的存储过程,还想请教各位
if exists(select name from sysobjects where type='p' and name='checkUserProc')drop procedure checkUserProc
go
create procedure checkUserProc(@checkResult int output,@checkUser varchar(50),@checkPassword varchar(100))
as
if exists(select userid,password,permission from Users_Info where userid=@checkUser and password=@checkPassword)
set @checkResult=1--通过验证
else
set @checkResult=0 --验证失败
return isnull(@checkResult,2)
go
CREATE PROCEDURE checkUserProc
@checkResult INT OUTPUT ,
@checkUser VARCHAR(50) ,
@checkPassword VARCHAR(100)
AS
SET NOCOUNT ON
SET @checkResult = -999
SELECT
@checkResult = permission
FROM Users_Info
WHERE userid = @checkUser
AND password = @checkPassword
RETURN @checkResult
--如果是-999,说明用户不存在或用户名密码错误;
--如果@checkResult <> -999,则验证成功,且@checkResult的值就是permission,返回即可
go