Microsoft SQL Server by default is case-insensitive which for the most part is very handy when searching and sorting data. There are times though where this isn't ideal, such as managing usernames or passwords.
If you take a look at the DDL of a table, you'll notice that most of your text-based columns including char and varchar fields use "COLLATE SQL_Latin1_General_CP1_CI_AS". If you would like certain columns to be case sensitive you will want to use "COLLATE SQL_Latin1_General_CP1_CS_AS" for your column definition. Please note the substitution of CI for CS in the collation statement.
If you don't have the option to change your column definition, there are a few other options to consider such as casting your columns to varbinary values when performing searches.
Hey, your post turned up when I did a google search - this is exactly the info I was looking for! Thanks!
ReplyDeleteBPS in Colorado
dito
ReplyDeleteGood information....Thanks a lot..
ReplyDeleteISMAIL
Techgate Technologies
yeeeeeup. worke for me too. awesome.
ReplyDeletePrecisely what I needed, thanks.
ReplyDeleteThe varbinary tip rocks! After hours of fails using COLLATE, a simple cast to varbinary works.
ReplyDeletethanks a lot..for
ReplyDeleteexact sol