将SQL Server排序规则从区分大小写更改为不区分大小写? [英] Changing SQL Server collation to case insensitive from case sensitive?

查看:136
本文介绍了将SQL Server排序规则从区分大小写更改为不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了SQL Server 2008,并且选择排序规则为区分大小写。我想使整个实例不区分大小写(而不是该实例中的数据库)。如果更改排序规则,是否会影响任何现有数据库?

I've recently installed SQL Server 2008 and I selected collation as case sensitive. I want to make it case insensitive for the entire instance (not for a database in that instance). If I change the collation does it affect any existing databases? if so in what way?

推荐答案

您基本上需要再次运行安装程序来重建 master 具有新排序规则的数据库。您无法通过其他任何方式更改整个服务器的排序规则。

You basically need to run the installation again to rebuild the master database with the new collation. You cannot change the entire server's collation any other way.

请参阅:

  • MSDN: Setting and changing the server collation
  • How to change database or server collation (in the middle of the page)

更新::如果要更改数据库的排序规则,则可以获取当前的排序规则使用以下T-SQL代码段:

Update: if you want to change the collation of a database, you can get the current collation using this snippet of T-SQL:

SELECT name, collation_name 
FROM sys.databases
WHERE name = 'test2'   -- put your database name here

这将产生类似以下的值:

This will yield a value something like:

Latin1_General_CI_AS

_CI 表示不区分大小写-如果要区分大小写,请在其位置使用 _CS

The _CI means "case insensitive" - if you want case-sensitive, use _CS in its place:

Latin1_General_CS_AS

所以您的T-SQL命令为:

So your T-SQL command would be:

ALTER DATABASE test2 -- put your database name here
   COLLATE Latin1_General_CS_AS   -- replace with whatever collation you need

您可以使用以下命令获取服务器上所有可用排序规则的列表:

You can get a list of all available collations on the server using:

SELECT * FROM ::fn_helpcollations()

您可以看到 服务器的 当前排序规则,使用以下命令:

You can see the server's current collation using:

SELECT SERVERPROPERTY ('Collation')

这篇关于将SQL Server排序规则从区分大小写更改为不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆