Collation of SQL SERVER

Source: Internet
Author: User

Sometimes when querying the database will be found (such as when the name of the duplicate check): The database query is not sensitive to case, that is, a and a are the same.

That is to say select * from tabletest where name = ' A ' and select * from tabletest where name = ' a '

Two SQL statements are executed the same way.

How to do it ... Baidu a bit, only to understand that this is related to the SQL SERVER collation. I had seen this option before when I installed SQL SERVER, but I didn't know what it meant ...

Perhaps this collation of the translation is also more confusing, the English original is collation, check the dictionary, as if the meaning of proofreading, anyway, did not see the meaning of the order.

But this thing is also really related to the sort, such as a series of names (Chinese) data, you can specify to sort by Pinyin (chinese_prc_), or Sort by stroke (chinese_prc_stroke_) or something ...

More sorting rules can be viewed: https://technet.microsoft.com/zh-cn/library/ms188046.aspx

Here is to solve the case-sensitive problem, OK, also in the above page has an explanation, you can set the following parameters:

Casesensitivity
The CI specifies case-insensitive, and the CS -specified sensitivity is casing-sensitive.
Accentsensitivity
AI Specifies accent-insensitive, as specifies accent sensitivity.
Kanatypesensitive
omitted Specifies that kana types are not distinguished, and KS specifies kana-sensitive types.
Widthsensitivity
The omitted specifies that the full half angle is not distinguished, and the WS specifies a full-width difference.

The SQL statement that sets the collation is:

COLLATE Chinese_prc_cs_as_ks_ws

The first half is sort-related, and the second half is the four options listed above, and you can add changes as needed ... Specifically how to add ...

-- or Baidu, or look at the above MSDN link inside the example, do not want to write ... 

Msdn:https://technet.microsoft.com/zh-cn/library/ff848763.aspx

The collation can be set on the server, or the database can be set, or the columns in the data table can be set, or the accompanying

In addition to using the SQL statement settings, you can also set it through the SSMS graphical interface:

Server settings may be troublesome, you need to stop the server or something, it is best to set the installation time

The database has a drop-down list in the Direct Properties option to select Settings.

For columns in a data table, you can set the column properties below the Table Designer

Well, there is also a graphical interface to select options ('? ') )

Please forgive me for writing simple ... Finish

Collation of SQL SERVER

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.