SQL case sensitive queries

SQL case sensitive queries

-
-

»WHERE username = 'username' COLLATE SQL_Latin1_General_CP1_CS_AS

// Where CS in the end stands for Case Sensitive. If you change it with CI, you'll get Case INsensitive.

»WHERE CAST(username AS varbinary(8)) = CAST('username' AS varbinary(8))

// This works because the binary version of e.g. 'a' isn't equal to 'A'.

Leave a Reply