SQL Server Force Case sensitivity method, SQL case sensitivity

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.