简体   繁体   English

设置和更改SQL Server排序规则

[英]Setting and Changing the SQL Server Collation

I have one question, I was trying to find more information on the internet but, I'm still not sure about it. 我有一个问题,我试图在互联网上找到更多信息,但是我仍然不确定。

If I have a SQL Server instance with the following default Collation example "Modern_Spanish_CI_AS" and I also have a restored databse with different collation example "Latin1_General_CI_AS". 如果我有一个带有以下默认排序规则示例“ Modern_Spanish_CI_AS”的SQL Server实例,并且还具有一个具有不同排序规则示例“ Latin1_General_CI_AS”的已还原数据库。

What collation SQL Server will use? SQL Server将使用哪种排序规则? by default the Modern_Spanish... or it will use from database Latin1_General? 默认情况下为Modern_Spanish ...还是将使用数据库Latin1_General?

In the follwing link explains something about it Setting and Changing the Server Collation 在下面的链接中解释了有关此问题的内容设置和更改服务器排序规则

Thanks! 谢谢!

It will use the Latin1_General_CI_AS collation, as that's what's set in the database itself. 它将使用Latin1_General_CI_AS归类,因为这是数据库本身设置的。

For clarification, whatever's set in the database will override the "default" collation for the server. 为了澄清起见,数据库中设置的任何内容都将覆盖服务器的“默认”排序规则。 The default collation is basically only used when you create a brand new database. 基本上,默认排序规则仅在创建全新数据库时使用。

Changing the default collation at the server level has no effect on existing databases, you would have to change each collation individually, though that in itself will probably cause you cascading issues with any other database level objects you've created, such as stored procedures, constraints and even any dynamic SQL you're executing against the database from 3rd party applications. 在服务器级别更改默认排序规则不会对现有数据库产生影响,您必须单独更改每个排序规则,尽管这本身可能会导致您与创建的任何其他数据库级别对象(例如存储过程,约束,甚至是您从第三方应用程序针对数据库执行的任何动态SQL。

SQL Server collations can be set at various levels: server, database, column, expession. 可以在各种级别上设置SQL Server排序规则:服务器,数据库,列,扩展。 If you do not set a collation at a lower level it is inherited from the level above. 如果您未将排序规则设置为较低级别,则它将从上一级继承。 Eg when creating a database the database collation will be the server's collation unless you explicitly set a collation for the DB. 例如,在创建数据库时,除非您为数据库明确设置了排序规则,否则数据库排序规则将是服务器的排序规则。

And many collations will work together fine. 并且许多排序规则可以很好地协同工作。 Occasionally there can be difficulties, often of the nature of sort order being unexpected. 有时可能会遇到困难,排序顺序通常是意料之外的。 I do not know for sure but I would expect the 2 you specify to be compatible. 我不确定,但我希望您指定的2是兼容的。

So yes, your DB will (almost certainly) restore with the Latin1_General_CI_AS collation and almost certainly be fine. 因此,是的,您的数据库将(几乎可以肯定)使用Latin1_General_CI_AS归类进行还原,并且几乎可以确定。 There is a list of compatible collations which Google should be able to help you find. Google可以帮助您找到兼容的归类列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM