有数据库DB 有表biao biao 里有字段userName 和userPass
比如说输入用户名admin和密码admin 
来判断用户名和密码是否正确,如果正确返回1否则返回0

解决方案 »

  1.   

    use DB
    go
    if(select * from sysobjects where object_id('prcLogin') is not null)
    drop proc prcLogin
    go
    create proc prcLogin @username char(20), @password char(10)
    as
    if not exists(select * from biao where userName = @username)
    begin
    print 'Not Found User : '+@username
    return 1
    end
    if (select UserPass from biao where userName=@username) <> @password
    begin
    print 'Password Error'
    return 1
    end
    print 'Login OK'
    return 0
    go
      

  2.   

    declare @iselect @i=count(*) from biao where userName ='admin' and userPass='admin'
    if @i>0
     select 1
    else
     select 0