SQL Server defaults to case-insensitive queries, but sometimes some query statements require a case-sensitive query, which requires some special handling. There are two main ways of distinguishing between case and case.
Turn binary judgment
SELECT * FROM table where CAST (name as varbinary) =cast (' Liyuanba ' as varbinary) -Short String select * from table where CAST (n Ame as varbinary) =cast (' Liyuanbaabcedef ... ' as varbinary (500))--long string
Attention
varbinary default length is 30, if the length is not enough to keep out of the part, resulting in a judgment error!
By Collate Chinese_prc_cs_as
SELECT * FROM table where name collate chinese_prc_cs_as= ' Liyuanba ' --exact select * from table where name collate Chinese _prc_cs_as like ' liyuanba% ' --Blur
Advantages
It is recommended that you do not need to consider string length issues.
SQL Server Case Sensitive query