SQL Server Force Case sensitivity method, SQL case sensitivity
1. Change a power system in the database to case sensitive. For example, if you want to modify the userPWD14 column in the table tb_TestTable400
<span style="font-size:14px;">ALTER TABLE tb_TestTable400ALTER COLUMN userPWD14 nvarchar(128) COLLATE Chinese_PRC_CS_AS</span>
2. Specify case insensitive in SQL statements:
<span style="font-size:14px;">select * from tb_TestTable400where userPWD14 ='VaNny' COLLATE Chinese_PRC_CI_AS</span>
Case Sensitive:
<span style="font-size:14px;">select * from tb_TestTable400where userPWD14 ='VaNny' COLLATE Chinese_PRC_CS_AS</span>
3. forcibly change the entire database to case sensitive (I don't know why it doesn't work after the test)
<span style="font-size:14px;">alter database databaseName COLLATE Chinese_PRC_CS_AS</span>
If the preceding statement execution reports the following error:
<Span style = "font-size: 14px;"> row 5030, level 16, status 2, and 1st cannot lock the database with exclusive locks to perform this operation. Failed to alter database for message 5072, level 16, status 1, and 1st rows. The default sorting rule for database 'test' cannot be set to Chinese_PRC_CS_AI. </Span>
Restart the mssqlserver service.
Note: When installing SQL Server, you should consider the sorting method and whether to differentiate the case sensitivity.