Sunday 24 December 2017

Case Sensitive Search in Sql Server.

In this article, We will discuss about How to do a Case Sensitive Search in Sql Server.

By default, Sql Server is Case Insensitive.

Before, We apply Case Sensitive Search in Sql Server first of all we need to check whether that particular column is Case Sensitive or Case InSensitive.

Below is an example to Check for a particular column whether it is Case Sensitive or Case InSensitive.


As the above Column is Case Insensitive, So we need to Convert that Column into Case Sensitive.

So While Searching only We will Convert that Case Insensitive Column into Case Sensitive Column Without altering the table(even if we can alter the table also).

Case Sensitive = SQL_Latin1_General_CP1_CS_AS
CaseInSensitive = SQL_Latin1_General_CP1_CI_AS


The query looks like as below,

select * from LoginDet where VarPwd='DotNet' collate SQL_Latin1_General_CP1_CS_AS

So, the output is looks like as below figure,


As you can see in the above image,  VarPwd='DotNet' matched with Case Sensitive So it returned the result.

But let's  Changed our Search String from VarPwd='DotNet' to VarPwd='dotNet' and it Will return no result because by using Case Sensitive Search it won't able to find that String  and which is shown in below figure,


0 comments:

Post a Comment