How SQL Server enforces case sensitivity

Source: Internet
Author: User

1. Forcing a column in the database to be changed to case -sensitive recognitionFor example, to modify a table: userPWD14 column in tb_testtable400
<span style= "FONT-SIZE:14PX;" >alter TABLE tb_testtable400alter COLUMN  userPWD14  nvarchar (+) COLLATE chinese_prc_cs_as</span>
2. Specify in the SQL statement Case insensitive :
<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. Change the entire database to case-sensitive (after testing, do not know why no effect)
<span style= "FONT-SIZE:14PX;" >alter Database DatabaseName COLLATE chinese_prc_cs_as</span>
If the above statement performs the following error:
<span style= "FONT-SIZE:14PX;" > Msg 5030, Level 16, State 2, line 1th cannot lock the database with an exclusive lock to perform the operation. Msg 5072, Level 16, State 1, Row 1th, alter DATABASE failed. The default collation for database ' Test ' cannot be set to Chinese_prc_cs_ai. </span>
Restart the MSSQLServer service
Small bet: When you install SQL Server, you should consider how the sorting is done and whether the case distinguishes the details.



How SQL Server enforces case sensitivity

Related Article

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.