SQL Productivity Tips

How to Make SQL Like Case Sensitive

Want to learn the simplest way to make SQL Like searches case sensitive? Here's the fastest way we found to do case sensitive SQL searches using WHERE and LIKE.

I realized that SQL is case insensitive when I tried to find articles in my article database that did not conform to proper case capitalization.

For example, I knew there were a few URLs that contained the word "founder" with a lower case "f" when they should have been capitalized with an upper case "F" to be "Founder" - and thus be consistent with the rest of the articles on our Entrepreneur Resources site.

So I hopped over to SQL Server and ran a query very similar to this:

SELECT * FROM ARTICLEDB WHERE ARTICLE_FILENAME LIKE '%-founder%'

Of course, I got back instances of URLs that contained both "-Founder" and "-founder" because SQL SELECT statements with SQL WHERE and SQL LIKE are by nature case insensitive.

I did a quick search for a fix to my SQL case problem, and discovered that this SELECT statement does the trick:

SELECT * FROM ARTICLEDB WHERE ARTICLE_FILENAME COLLATE Latin1_General_BIN LIKE '%-founder%'

Long story short, the way to make an SQL select statement case sensitive is to add in that "COLLATE Latin1_General_BIN" after the column name.

Why does it work? How does it work? What other ways are there to do it? I do not know and could care less.

If you want to truly understand this stuff, there are plenty of long articles on SQL case sensitivity.

If you just need a quick fix that works, try the above method to make an SQL SELECT case sensitive rather than case insensitive, which is the default.

Share this article


Additional Resources for Entrepreneurs

Lists of Venture Capital and Private Equity Firms

Franchise Opportunities

Contributors

Business Glossary

 

Conversation Board

Dealing with SQL case sentitive issues? Feel free to ask a question. We also welcome any SQL tips and comments related to SQL select statements and case sensitivity.


Leave a Reply

Questions, Comments, Tips, and Advice

Email will not be posted or shared
Code Image - Please contact webmaster if you have problems seeing this image code

Problem Viewing Image? Load New Code