Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Case-sensitive string comparision to validate password

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-29 : 12:09:36
Sunitha writes "Hi !

I am having problems being not able to compare strings with case-sensitivity. Here is the stored procedure that I am using :


/****** Object: Stored Procedure dbo.usp_ValidateLogin Script Date: 12/22/2001 12:41:34 AM ******/
CREATE PROCEDURE usp_ValidateLogin 
@inLogin varchar(10),
@inPassword varchar(10)
AS
Declare @tempCount int
Declare @outLoginStatus char(2)
Declare @outEmpId int
Declare @outRoleId smallint

BEGIN
set @inLogin = UPPER(RTRIM(LTRIM(@inLogin)))
set @inPassword = RTRIM(LTRIM(@inPassword))
set @inPassword = CAST(@inPassword AS varbinary(10)) -- trick for case sensitive comparision

set @outLoginStatus = 'WL' -- Default - Wrong Login
set @outEmpId = 0 -- Default ' Employee doesn't exist
set @outRoleId = 0 --Default

Select @tempCount = count(EmpId) from Employees where (UPPER(ELogin)=@inLogin)
if @tempCount = 0
Begin
set @outLoginStatus = 'WL'
set @outEmpId = 0 -- Default
set @outRoleId = 0 --Default
select @outLoginStatus, @outEmpId, @outRoleId
End
Else
Begin
select @tempCount = count(EmpId) from Employees Where((UPPER(ELogin)=@inLogin) and (CAST(EPassword as varbinary(10))=@inPassword)) ---> THIS IS NOT WORKING
If (@tempCount = 0)
Begin
set @outLoginStatus = 'WP'
select @outLoginStatus, @outEmpId, @outRoleId
End
Else
Begin
set @outLoginStatus = 'LP'
select @outEmpId = EmpId, @outRoleId = RoleId from Employees where ((UPPER(ELogin)=@inLogin) and (EPassword=@inPassword))
select @outLoginStatus, @outEmpId, @outRoleId
End
End
END
GO
**************************************************************


I am unable to do case-sensitive comparision of the password. Please Help !!!

Thanks
Sunitha"

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-29 : 15:25:19
If you are using v2000 you can also coerce the collation probably.

looking at the code
try not converting to varbinary and saving the result in a varchar (which will do another implict convertion)

CAST(EPassword as varbinary(10))=CAST(@inPassword as varbinary(10))

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -