Skip to content

Conversation

@srutzky
Copy link
Contributor

@srutzky srutzky commented Mar 7, 2019

This is the first in a series of PRs to correct and/or complete various pages related to collations and/or Unicode support. Some of the pages, such as the one for Windows Collations, were missing updates starting with SQL Server 2012.

The two pages updated in this PR will be updated again, sometime soon, to include the new UTF-8 collations introduced in SQL Server 2019.

COLLATIONPROPERTY

  1. Removed SQL Server version number from intro / summary. Behavior of this function does not vary between versions of SQL Server.

  2. Improved wording of "LCID" definition: Defining LCID as LCID didn't give the reader any new information.

  3. Improved wording of "Comparison" definition: A) Removed the word "case" (added by @fbsolo on 2018-04-23 via PR Update collation-functions-collationproperty-transact-sql.md #566 ) as it should not have been added. Properties cannot be case-sensitive. "Case" is a property that can be either sensitive or insensitive. B) added collation variations that have all sensitivities enabled. Unique variations for "everything-sensitive" collations found using the following query:

    SELECT DISTINCT
           SUBSTRING(col.[name], PATINDEX(N'%[_][BC][IS]%', col.[name]), 100) AS [Sensitivities]
    FROM   sys.fn_helpcollations() col
    WHERE  CONVERT(INT, COLLATIONPROPERTY(col.[name], N'ComparisonStyle')) = 0
    ORDER BY [Sensitivities];
    /*
    _BIN
    _BIN2
    _CS_AS_KS_WS
    _CS_AS_KS_WS_SC
    _CS_AS_KS_WS_VSS
    */
  4. Improved wording of "Version" definition. The "derived from the collation ID version field" clause is awkward and has meaning to so few people that it really just confuses people.

  5. Added "Base data type" to each property (based on format use in ( https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql ). Data types discovered using the following query:

    SELECT SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'CodePage'),
                                'basetype'),
           SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'LCID'),
                                'basetype'),
           SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'ComparisonStyle'),
                                'basetype'),
           SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'Version'),
                                'basetype');
    -- int    int    int    tinyint

TO DO:

  1. Update "CodePage" definition to account for UTF-8
  2. Update "ComparisonStyle" definition to acknowledge that _SC and _UTF8 options are not included in this property.

Windows Collations

  1. Added _VariationSelectorSensitive property (introduced in SQL Server 2017)

  2. Changed wording related to code pages to be "varchar" instead of "non-Unicode" since new UTF-8 collations in SQL Server 2019 use code page 65001 but are clearly not "non-Unicode" (this change will need to be made on several pages).

  3. Better formatting in section describing the various sensitivities.

  4. Updated wording and example code in Remarks section to make it clear that "undefined" in a particular collation does not mean that the character does not exist.

  5. Updated example Windows collations for correctness, consistency, and variety.

  6. Minor improvements to query to find Windows collations

TO DO:

  1. Add info about _SC collations (introduced in SQL Server 2012)
  2. Add info about _UTF8 collations (introduced in SQL Server 2019)
  3. Add info about collation version numbers (is in some places, but not everywhere it should be ; introduced in SQL Server 2005)
    All of that is waiting until binary UTF-8 collation(s) are settled as the introduction of it (so far UTF8_BIN2) changes the syntax description quite a bit, and will require careful thought about new wording since neither version number, nor _SC, nor _UTF8 apply to "CollationDesignator" or "<ComparisonStyle>".

…sql.md

1. Removed SQL Server version number from intro / summary. Behavior of this function does not vary between versions of SQL Server.

2. Improved wording of "LCID" definition: Defining LCID as LCID didn't give the reader any new information.

3. Improved wording of "Comparison" definition: A) Removed the word "case" (added by @fbsolo on 2018-04-23 via PR MicrosoftDocs#566 ) as it should not have been added. Properties cannot be case-sensitive. "Case" is a property that can be either sensitive or insensitive. B) added collation variations that have all sensitivities enabled. Unique variations for "everything-sensitive" collations found using the following query:

SELECT DISTINCT SUBSTRING(col.[name], PATINDEX(N'%[_][BC][IS]%', col.[name]), 100) AS [Sensitivities]
FROM   sys.fn_helpcollations() col
WHERE  CONVERT(INT, COLLATIONPROPERTY(col.[name], N'ComparisonStyle')) = 0
ORDER BY [Sensitivities];
/*
_BIN
_BIN2
_CS_AS_KS_WS
_CS_AS_KS_WS_SC
_CS_AS_KS_WS_VSS
*/

4. Improved wording of "Version" definition. The "derived from the collation ID version field" clause is awkward and has meaning to so few people that it really just confuses people. 

5. Added "Base data type" to each property (based on format use in ( https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql ). Data types discovered using the following query:

SELECT SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'CodePage'), 'basetype'),
       SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'LCID'), 'basetype'),
       SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'ComparisonStyle'), 'basetype'),
       SQL_VARIANT_PROPERTY(COLLATIONPROPERTY(N'Hebrew_100_CS_AS', N'Version'), 'basetype');
-- int    int    int    tinyint
1. Added **_VariationSelectorSensitive ** property (introduced in SQL Server 2017)

2. Changed wording related to code pages to be "**varchar**" instead of  "non-Unicode" since new UTF-8 collations in SQL Server 2019 use code page 65001 but are clearly not "non-Unicode" (this change will need to be made on several pages).

3. Better formatting in section describing the various sensitivities.

4. Updated wording and example code in **Remarks** section to make it clear that "undefined" in a particular collation does _not_ mean that the character does not exist.

5. Updated example Windows collations for correctness, consistency, and variety.

6.  Minor improvements to query to find Windows collations

TO DO:
1. Add info about _SC collations
2. Add info about _UTF8 collations
3. Add info about collation version numbers
All of that is waiting until binary UTF-8 collation(s) are settled as the introduction of it (so far `UTF8_BIN2`) changes the syntax description quite a bit, and will require careful thought about new wording since neither version number, nor _SC, nor _UTF8 apply to "CollationDesignator" or "<ComparisonStyle>".
@PRMerger13
Copy link
Contributor

@srutzky : Thanks for your contribution! The author, @CarlRabeler, has been notified to review your proposed change.

@srutzky
Copy link
Contributor Author

srutzky commented Mar 7, 2019

Wow, thanks @CarlRabeler for the awesomely quick approval 😺 .

P.S. No set ETA on the forthcoming parts / phases of the collation/Unicode updates, but they are coming.

@CarlRabeler
Copy link
Contributor

CarlRabeler commented Mar 7, 2019 via email

@srutzky srutzky deleted the patch-2 branch July 9, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants