SQL Case Sensitive Select Query

Today I ran into a problem where I needed to search for the term “PROfile” in my SQL database. the problem was, my queries kept also showing “profile” without the caps. From reading many sites, I guess that depending on how your SQL server was setup, you’ll either have case sensitive or insensitive searches. to change this (not server wide but just for your current query):

For case sensitive:
WHERE body like ‘PROfile’ COLLATE SQL_Latin1_General_CP1_CS_AS

For case insensitive:
WHERE body like ‘profile’ COLLATE SQL_Latin1_General_CP1_CI_AS

(notice the CS for case sensitive and CI for insensitive)


Leave a Reply