![]() However, if you convert these strings to Unicode and you perform the same comparison, the Unicode string N'a-c' is considered to be greater than N'ab' because the Unicode sorting rules use a "word sort" that ignores the hyphen. For example, if you are using the SQL collation "SQL_Latin1_General_CP1_CI_AS", the non-Unicode string 'a-c' is less than the string 'ab' because the hyphen ("-") is sorted as a separate character that comes before "b". ![]() Because the comparison rules for non-Unicode and Unicode data are different, when you use a SQL collation you might see different results for comparisons of the same characters, depending on the underlying data type. SQL Server bases these comparison semantics on a SQL "sort order." For a mapping of sort orders to SQL collations, see the "SQL Collation Name" topic in SQL Server Books Online.Ī SQL collation's rules for sorting non-Unicode data are incompatible with any sort routine that is provided by the Microsoft Windows operating system however, the sorting of Unicode data is compatible with a particular version of the Windows sorting rules. In a SQL collation, SQL Server defines different comparison semantics for non-Unicode data. It also enables developers who use the CompareString Win32 API function to sort strings in their application by using the same rules that SQL Server uses. This provides consistency across data types in SQL Server. ![]() Both Unicode and non-Unicode sorting are compatible with string comparison rules in a particular version of Windows. More Information Collation semanticsįor a Windows collation, a comparison of non-Unicode data is implemented by using the same algorithm as Unicode data. This article discusses additional considerations that may affect your decision about whether to choose a Windows collation or a SQL collation when you install SQL Server 2000 or SQL Server 2005. SQL Server 2000 supports two types of collations:įor a description of each type of collation and a good overview of how to decide which collation to use, see the "Selecting Collations" topic in SQL Server 2000 Books Online, or see the "Collation Types" topic in SQL Server 2005 Books Online. In Microsoft SQL Server 2000 and in Microsoft SQL Server 2005, a "collation" specifies how strings are compared and sorted, and what character set is used for non-Unicode data.
0 Comments
Leave a Reply. |