sqlsql-serverexact-matchssms-19

WHERE clause with '=' operator doesn't return exact match


I tried a SELECT with a WHERE clause searching for a wrong string but the result showed the right string, which further testing showed the WHERE clause with the = operator doesn't return the exact match.

I have tried to search for solutions but can't find any through Google or Stack Overflow.

Simplified example

SELECT * 
FROM LoginCredential 
WHERE UserID = 'ad' 

The result


Solution

  • You question appears to have already been asked and has an answer here How to do a case sensitive search in WHERE clause (I'm using SQL Server)?

    For your easy reference:

    SELECT *
    From LoginCredential
    WHERE UserID = 'ad'  COLLATE SQL_Latin1_General_CP1_CS_AS