English 中文(简体)
Microsoft SQL Server排序规则名称
原标题:Microsoft SQL Server collation names

有人知道排序规则的WS属性的作用吗?这和亚洲类型的剧本有什么关系吗?MSDN文档将其解释为“宽度敏感”,但这对瑞典语或英语来说毫无意义。。。?

最佳回答

这里总结了宽度灵敏度的良好描述:http://www.databasejournal.com/features/mssql/article.php/3302341/SQL-Server-and-Collation.htm

宽度灵敏度

When a single-byte character (half-width) and the same character when represented as a double-byte character (full-width) are treated differently then it is width sensitive.

也许从英文字符的角度来看,我认为宽度敏感的排序规则意味着abc<>;N abc,因为一个字符串是Unicode字符串(每个字符2个字节),而另一个字符串每个字符1个字节。

从拉丁字符集的角度来看,这似乎是一个没有意义的设置。也许在其他语言中,这很重要。

通常,我会尝试将这些类型的排序规则属性设置为不敏感,以避免出现搜索结果中没有返回记录之类的奇怪情况。我通常将重音设置为不敏感,因为这可能会导致很多用户搜索问题,具体取决于应用程序的受众。

Edit: After creating a test database with the Latin1_General_CS_AS_WS collation, I found that the N a = N A is actually true. Test queries were:

select case when  a  =  A  then  yes  else  no  end
select case when  a  =  a  then  yes  else  no  end
select case when N a  =  a  then  yes  else  no  end 

所以在实践中,我不确定这种规则在哪里发挥作用

问题回答

接受的答案表明,它在比较中没有发挥作用N a=a。这很容易解释,因为在两者之间的比较中,char将被隐式转换为nchar,因此比较中的两个字符串都是Unicode。

我只是想到了一个例子,在拉丁语排序中,宽度敏感性可能会发挥作用,但却发现它似乎也没有任何区别。。。

DECLARE @T TABLE (
  a VARCHAR(2) COLLATE Latin1_General_100_CS_AS_WS,
  b VARCHAR(2) COLLATE Latin1_General_100_CS_AS_WS )

INSERT INTO @T
VALUES      (N Æ ,
             N AE );

SELECT LEN(a) AS [LEN(a)],
       LEN(b) AS [LEN(b)],
       a,
       b,
       CASE
         WHEN a = b THEN  Y 
         ELSE  N 
       END    AS [a=b]
FROM   @T 

LEN(a)      LEN(b)      a    b    a=b
----------- ----------- ---- ---- ----
1           2           Æ    AE   Y

《MicrosoftSQLServer2008Internals》一书就是这么说的。

Width Sensitivity refers to East Asian languages for which there exists both half-width and full-width forms of some characters.

只要列具有unicode数据类型,就绝对没有什么可以阻止您将这些字符存储在排序规则中,例如Latin1_General_100_CS_as_WS,所以我猜WS部分只适用于这种特定情况。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签