How to solve garbled characters in SQL SERVER2005

Source: Internet
Author: User

How to solve garbled characters in SQL SERVER2005

When using SQL SERVER2005, Chinese characters are often garbled. After research, we found that setting SQL sorting rules can solve this problem.

1. Log on to the Server and open Microsoft SQL Server Management Studio.

2. Right-click the database tutorial to be modified and select "properties ".

3. In the pop-up Database properties window, click "options" on the "select page ".

4. Change the sorting rule from SQL _Latin1_General_CP1_CI_AS to Chinese_PRC_CI_AS.

5. Click OK.


Change varchar to nvarchar
Char to nchar

Note: for example
Two methods:

1:

Do not select Hide advice configuration options during installation

Then select Chinese_PRC in Collation designator and order.

2:

Specifies the language of a field during table creation.

Method COLLATE Chinese_PRC_CS_AS_WS

Example:

Create table test
(
A varchar (255) COLLATE Chinese_PRC_CS_AS_WS NULL,
B varchar (255) COLLATE SQL _latin1_general_cp1_ci_as NULL
)

Insert test values ('Chinese', 'Chinese ')

After insertion, field a is Chinese, and field B is ??


Other references

Garbled characters are always displayed when Chinese characters are stored in the database. DEBUG found that both Chinese and Service are correct Chinese characters on the page. Change the field value in the database to Chinese (the field type is Nvarchar). The result page is displayed correctly, indicating that the page is correctly set. The problem lies in the database layer.

Then I checked the database connection field and found a parameter.

SendStringParametersAsUnicode = false

Change it to sendStringParametersAsUnicode = true to solve the problem.

Query MSDN information

 

If the sendStringParametersAsUnicode attribute is set to "true", the string parameter is sent to the server in Unicode format.

If the sendStringParametersAsUnicode attribute is set to "false", the string parameter is sent to the server in non-Unicode format (for example, ASCII/MBCS, not Unicode.

The default value of the sendStringParametersAsUnicode attribute is "true ".

 

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.