Collations on indexes in SQL Server

后端 未结 3 484
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 17:28

I am interested if there is a possibility to specify collation for a column when creating index that is different from the collation of that column? And when indexed, are st

3条回答
  •  清酒与你
    2021-01-11 17:39

    I don't believe you can. Although COLLATE is documented separately, you'll note that there are only 3 places listed where it can occur:

    • Creating or altering a database
    • Creating or altering a table column
    • Casting the collation of an expression

    Note that, for instance, in CREATE TABLE:

     ::=
    column_name 
        [ FILESTREAM ]
        [ COLLATE collation_name ] 
        ...
    

    that the COLLATE clause is explicitly mentioned.

    Whereas, in CREATE INDEX:

    CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name 
        ON  ( column [ ASC | DESC ] [ ,...n ] ) 
        ...
    
    
    

    note that all that is allowed here is a column - not a column definition, nor an expression.


    I believe the collation of each column within an index follows the collation of the underlying column(s) in the appropriate table. The database collation isn't used for much, so far as I'm aware, other than to supply a default collation to columns during CREATE/ALTER table statements.

    提交回复
    热议问题