problem with space

M

Mango

HI friends,

I've got one question. When I realize "log in" in my sql server, I am using
SP like this:

CREATE Procedure CustomerLogin

(

@Email nvarchar(30),

@Pwd nvarchar(10),

@CustomerID int OUTPUT

)

AS



SELECT

@CustomerID = CustomerID



FROM

Customers



WHERE

Email = @Email COLLATE SQL_Latin1_General_CP1_CS_AS

AND

Pwd =@Pwd COLLATE SQL_Latin1_General_CP1_CS_AS



IF @@Rowcount < 1

SELECT

@CustomerID = 0

GO



The problem is that if the password is "qweqwe" and I try to log in with
"qweqwe " or even "qweqwe " (I mean with space after last symbol) it
succeed!!!

Interesting but if I try to log in with " qweqwe" (I mean with space in
beginning) it not succeed.

I don't know why. Could you please somebody help me?
 
C

Chris Newman

sql server's euqal to comparitor isnt case sensative and also it trims white
space off the end! there is another one that will do it exactly - cant
remember what it is though but I have seen it!

it might do it with a LIKE comparison is you can tell it to match
exactly..... cant remember though
 
Õ

ÕÅÏþ³É

Najatte said:
Hi,

You can use the function LTRIM & RTRIM whcih gives you a better comaprison
than using the LIKE function
Syntaxe: Pwd =RTRIM(@Pwd) or Pwd =LTRIM(@Pwd)

The difference is below:
If you have two pwds in your table CUSTOMERS: qweqwe & testqweqwe
The LIKE function will return the boths records (Ex: LIKE '%qweqwe%')
But LTRIM& RTRIM will return the right record

Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top