Why is SQL Server '=' comparator case insensitive?

rkg picture rkg · Feb 8, 2011 · Viewed 16.9k times · Source

I just realized that SQL server '=' comparator when used for text comparison is case insensitive. I have a few questions regarding this functionality:

  1. Is this the same for all databases or specific to SQL server?
  2. I have been using the lower function to ensure the text comparison is insensitive till now. Is it still a good idea to follow the same?
  3. How can we do case sensitive comparisons in SQL server?
  4. Why is '=' operator defaulting to case insensitive comparison?

Answer

OMG Ponies picture OMG Ponies · Feb 8, 2011

No, case sensitivity has nothing to do with the equals sign.

Case sensitivity is determined by the collation for the database -- see the documentation for details.