Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of Chinese garbled Code in SqlServer Database

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to solve the SqlServer database Chinese garbled phenomenon", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to solve the SqlServer database Chinese garbled phenomenon" it!

Cause analysis: the garbled code problem in the SQL version still appears in the installation settings of SQL SERVER. Default installation of the system default collation is the Latin collation, but most people do not take this into account during installation, installation only click the next step, after the installation is completed, resulting in SQL version in the use of garbled code.

Solution 1:

If you are creating a new database, you can specify the collation when creating the data, and remember to select simplified Chinese (Chinese_PRC_CS_AI_WS). If you already have data in the database, the conversion will fail.

Operation steps

1. Right-click the database property

two。 Click "options" to modify the sorting method

Solution 2:

The most thorough thing is to reinstall SQL, customize the installation during installation, choose the language version and sorting rules, and the problem will be solved.

The parameters are explained as follows:

The first half: refers to the UNICODE character set, and Chinese_PRC_ refers to the sorting rules for mainland simplified characters UNICODE.

The second half of the collation is the suffix meaning:

_ BIN binary sort

Whether CI (CS) is case-sensitive, CI is not case-sensitive, CS is case-sensitive

Whether _ AI (AS) distinguishes stress, AI does not distinguish, AS distinguishes

Whether _ KI (KS) distinguishes katakana types, KI does not distinguish, KS distinguishes

Whether _ WI (WS) distinguishes width WI does not distinguish, WS distinguishes

Case sensitive: select this option if you want the comparison to treat uppercase and lowercase letters as unequal.

Distinguish stress: select this option if you want accented and unstressed letters to be treated as unequal. If you select this option

The comparison also treats letters with different stresses as unequal.

Distinguish katakana: select this option if you want the comparison to treat katakana and katakana Japanese syllables as unequal.

Distinguish width: select this option if you want the comparison to treat half-width characters and full-width characters as unequal

Sqlserver database building assigns utf-8 modification library to utf-8 coding

CREATE DATABASE paas COLLATE Chinese_PRC_CI_AS

GO

ALTER DATABASE paas COLLATE Chinese_PRC_CI_AS

GO

Let ASP and MS SQL SERVER support UTF-8 encoding and storage of multiple languages and characters

Recently, when storing UTF-8 coding content in ASP+MS SQL, there was garbled. After query, it was found that in order to make SQL SERVER support UTF-8 coding format, some modifications must be made.

1. Make sure that the ASP page is UTF-8-encoded and used in the declaration at the top of the ASP page for encoding declaration

2. Declare the character set in the output HTML page:

3. When passing URL parameters, you should use the Server.URLEncode () method to encode

4. When you use JS to pass URL parameters in Chinese, you should use escape to encode

5. When storing UTF-8-encoded content in SQL SERVER database, the fields to be stored must be set to NVARCHAR type. The SQL statement should be preceded by N, such as insert into user (name) values (N'& username&'), except for unexpected fields in id.

Check out more here: http://msdn.microsoft.com/en-us/library/ms186939.aspx

Character data types are fixed length, nchar, or variable length, nvarchar,unicode data, and use the Unicode UCS-2 character set.

It's also here: http://en.wikipara.org/wiki/utf-16

The earlier ucs-2 (2-byte universal character set) was a similar character encoding that was replaced by utf-16 in version 2.0 of the Unicode standard in July 1996.

Thank you for your reading, the above is the content of "how to solve the Chinese garbled phenomenon in SqlServer database". After the study of this article, I believe you have a deeper understanding of how to solve the problem of Chinese garbled in SqlServer database, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report