Skip to main content

Posts

Showing posts with the label Select query

How to do a Case-Sensitive SQL Server Query

When selecting data in SQL Server, the WHERE-clause has, in my experience, ignored the case and done a case-insensitive comparison. For example, my Individuals table may have a mix of upper and lower cases, depending on how people entered their names: SELECT firstname, lastname  FROM Individuals WHERE lastname = 'Timmins' firstname lastname --------- -------- Tammy TIMMINS Tellie timmins Tommy TimMinS Tubby Timmins My query selected all four people with the last name "Timmins" without caring if it was all capitals, all lower case, or a mixture. I rely on that behavior all the time. But once in a while, we need to do a case-sensitive query. How can we, for example, find Tommy TimMinS and correct it to Tommy Timmins?