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

No comments:

Post a Comment

Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author