Modify the sorting rules of the LocalDB database and fix question marks for Chinese Characters

Source: Internet
Author: User

VS2012 and VS2013 Add a lightweight database LocalDB. With this, developers do not have to install a large SQL server to conveniently test and run small projects. Since it is a lightweight database, it discards a huge body and is also limited in functionality. One of them is its default sorting rules, which are used by default, chinese data added from the front-end of the website displays garbled characters or question marks in the database. This problem has plagued me for several days and finally found a solution through various searches, hope to help you with the same confusion!
1. Right-click the database instance, create a query, and change the database to single-user mode.

Alter database [database name or full path] set single_user with rollback immediate;
Go

2. Modify the sorting rule (Chinese here -- Pinyin -- case-insensitive)

Alter database [database name or full path] collate Chinese_PRC_CI_AS;
Go

3. Reset to multi-user mode

Alter database [database name or full path] set multi_user;

The name of a sorting rule consists of two parts. The first half is the character set supported by this sorting rule.
For example:
Chinese_PRC_CS_AI_WS
First half: the UNICODE character set. The Chinese_PRC _ pointer sorts UNICODE in simplified Chinese characters. The second half of the sorting rule is the suffix meaning:

_ BIN binary sorting

_ CI (CS) is case sensitive, CI is case insensitive, and CS is case sensitive: select this option if you want to compare uppercase and lowercase letters.

_ Whether AI (AS) is accent-sensitive, while AI is not. AS is accent-sensitive: select this option if you want to treat accent and non-accent letters AS different. If this option is selected, the comparison also treats letters with different accents as unequal.

Whether the _ KI (KS) class is Kana-type. kks-type is Kana-type. Kana-type is Kana-type. If you want to compare the Katakana and Japanese syllables, select this option.

_ WI (WS) Whether to differentiate width without WI, WS distinguishes between width: select this option if you want to compare half-width and full-width characters.

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.