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
[SQL] view plain copy
- Alter database [DB name or full path] set Single_user with rollback immediate;
- Go
2. Modify the collation (Chinese--Pinyin--not case sensitive)
[SQL] view plain copy
- Alter database [DB name or full path] collate chinese_prc_ci_as;
- Go
3. Reset to multi-user mode
[SQL] view plain copy
- Alter database [DB name or full path] set multi_user;
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:
[SQL]View PlainCopy
- --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;
http://blog.csdn.net/u011127019/article/details/51705213
LocalDB database Modify collation to fix Chinese character change question mark