SQL Server – Case-Sensitive search in SQL

If your sql server is installed with the default collation of case-insensitive, you can accomplish this in sql instead.

You can determine if your installation collation is case-insensitive by running this query:

SELECT SERVERPROPERTY ('Collation')
GO

If the result is Collate SQL_Latin1_General_CP1_CI_AS, then it it is case-insensitive.

For example, I may have data stored in column as AbC and ABC. I want only rows where the column = ‘AbC’

You can accomplish this by using the Collate method in sql to tell your installation that you want to override the default property with the case-sensitive property like this (SQL_Latin1_General_CP1_CS_AS):

SELECT *
 FROM dbo.some_table
 WHERE some_value = 'AbC' Collate SQL_Latin1_General_CP1_CS_AS

Leave a Reply