Wednesday, June 11, 2008

SQL Server Case Sensitive or case insensitive Quries

When we need That Comparison in SQL server should be Case Sensitive or Case Insensitive Regardless Database is configured or Not for Case Sensitivity We can Write Such Queries Using Following Syntax.

By default queries behave as per Database configured.

(1)Default Query:

SELECT * FROM Members WHERE Email = ‘mailto:dhameliyaharesh@gmail.com%27

(2)Case Sensitive Query:

SELECT * FROM Members WHERE Email = ‘mailto:dhameliyaharesh@gmail.com%27 COLLATE SQL_Latin1_General_CP1_CS_AS

Above query will matches dhameliyaharesh@gmail.com And Not Matches DHAMELIYAHARESH@GMAIL.COM

(3)Case Insensitive Query:

SELECT * FROM Members WHERE Email = ‘mailto:dhameliyaharesh@gmail.com%27 COLLATE SQL_Latin1_General_CP1_CI_AS

Above query will matches dhameliyaharesh@gmail.com as well as DHAMELIYAHARESH@GMAIL.COM