tags:

views:

59

answers:

2

How do you compare strings so that the comparison is true only if the cases of each of the strings are equal as well. For example:

Select * from a_table where attribute = 'k'

...will return a row with an attribute of 'K'. I do not want this behaviour.

A: 

You can define attribute as BINARY or use INSTR or STRCMP to perform your search.

MatTheCat
+2  A: 
Select * from a_table where attribute = 'k' COLLATE Latin1_General_CS_AS 

Did the trick.

amccormack
I'd normally use Latin1_General_Bin
gbn
Yes, the Standard approach is to use a case-insensitive collation, though the collations themselves are vendor-specific. Is yours SQL Server syntax?
onedaywhen