LocalDB database Modify collation, fix Chinese character change question mark

Source: Internet
Author: User

VS in the new lightweight database localdb, there is this, the developer will not have to install a large SQL Server, can easily test running small projects, since it is a lightweight database, it abandoned a large body, of course, will also be limited, one of which is its default collation, Using the default collation, the Chinese data added from the Web site foreground displays garbled or variable question marks in the database; This problem has troubled me for several days, through a variety of search, finally found a solution; I would like to help you with the same confusion!

New database Default collation is: SQL_Latin1_General_CP1_CI_AS, if the use of Chinese will appear garbled, display question mark

1. Right-click DB instance, new query modifies database to single user mode

Set Single_user with rollback  immediate;  Go  

2. Modify the collation (Chinese--Pinyin--not case sensitive)

ALTER DATABASE [DB name or full path] collate chinese_prc_ci_as;  Go  

3. Reset to multi-user mode

ALTER DATABASE [DB name or full path]  set

Where the collation name is composed of two parts, the first half refers to the character set supported by this collation.
Such as:
Chinese_prc_cs_ai_ws
First half: Refers to the Unicode character set, chinese_prc_ the pointer to the mainland simplified Unicode collation. The second half of the collation is the suffix meaning:

_bin binary Ordering

_ci (CS) is case sensitive, CI is not differentiated, CS is case sensitive: Select this option if you want comparisons to treat uppercase and lowercase letters as unequal.

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

_ki (KS) Whether the kana type is differentiated, KI does not differentiate, KS differentiates kana: Select this option if you want the comparison to treat katakana and hiragana Japanese syllables as unequal.

_WI (WS) Whether the width of the WI is not differentiated, the WS differentiates the width: Select this option if you want the comparison to treat half-width characters and full-width characters as unequal

Usage examples:

-- The first step to close all connections    to the current data -- Step Two: Execute the Modify collation statement  ALTER DATABASE   [F:\ANGULAR_SOLUTION\BOOKSTRAP_ Adminlte_demo\bookstrap_adminlte_demo\app_data\student.mdf]   collate chinese_prc_cs_ai_ws;    

Reprint: http://blog.csdn.net/u011127019/article/details/51705213

LocalDB database Modify collation, fix Chinese character change question mark

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.