String comparison on SQL Server

amir100

Well-known member
Joined
Mar 14, 2004
Messages
190
Location
Indonesia
Hi all,

I have a case here. I have a table named "user" with two fields, "username" and "password". Within the table, I have three records with username "adin", "anida", and "admin".

I tried this query:
Code:
SELECT     username
FROM         users
WHERE     (username = Adin)

I expect the query returns 0 result. But no, the query returns 1 row, the row with the username "adin".

Can someone explain whats wrong? Thanks.
 
penfold69 said:
String comparisons are case-insensitive, unless you explicitly state that they need to be case-sensitive.

How you do that can depend on the server youre using. For SQL server, check out:

http://vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm

B.

As penfold69 said, but having a case sensitive or not database depends on the collation you are using, check the SQL Books documents to see which collation is cases-insensitive in your language
 
iebidan said:
As penfold69 said, but having a case sensitive or not database depends on the collation you are using, check the SQL Books documents to see which collation is cases-insensitive in your language

Yupe, I guess its the collation. The link refered by penfold69 is great. The articles shows many methods to solve my problem. The one I choose is changing the collation of the column directly to the server.

Thx for the help.
:D
 
Back
Top