Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I want to do a case sensitive search in my SQL query. But by default, SQL Server does not consider the case of the strings.

Any idea on how to do a case sensitive search in SQL query?

1 Answer

0 votes
by (40.4k points)

A case sensitive search in WHERE clause can be done via changing the Collation. Because, by default, it is case insensitive.

Try this code:

SELECT 1

FROM dbo.Customers

WHERE   CustID = @CustID COLLATE SQL_Latin1_General_CP1_CS_AS

    AND CustPassword = @CustPassword COLLATE SQL_Latin1_General_CP1_CS_AS

Otherwise, change the columns to be case sensitive.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 11, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)

Browse Categories

...