Case Sensitive SQL

In SQL Server you can use COLLATE Latin1_General_CS_AS in your SQL to perform case sensitive queries.  However, if you need to do case sensitive queries you may want to consider altering the column so that it is case sensitive.  If that is not an option, here is how to use SQL.

How to select case sensitive:

select *
  from TableName
where FieldName = ‘xYz COLLATE Latin1_General_CS_AS

How to group by using case sensitive:

select FieldName COLLATE Latin1_General_CS_AS, count(*)
  from TableName
group by FieldName COLLATE Latin1_General_CS_AS

Explore posts in the same categories: SQL Server


You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: