SQL Server case insensitive collation

前端 未结 5 1701
忘了有多久
忘了有多久 2021-02-07 22:29

What are the benefits/drawbacks of using a case insensitive collation in SQL Server (in terms of query performance)?

I have a database that is currently using a case-ins

5条回答
  •  终归单人心
    2021-02-07 22:59

    If you change the collation on the database, you also have to change it on each column individually - they maintain the collation setting that was in force when their table was created.

    create database CollTest COLLATE Latin1_General_CI_AI
    go
    use CollTest
    go
    create table T1 (
        ID int not null,
        Val1 varchar(50) not null
    )
    go
    select name,collation_name from sys.columns where name='Val1'
    go
    alter database CollTest COLLATE Latin1_General_CS_AS
    go
    select name,collation_name from sys.columns where name='Val1'
    go
    

    Result:

    name collation_name
    ---- --------------
    Val1 Latin1_General_CI_AI
    
    name collation_name
    ---- --------------
    Val1 Latin1_General_CI_AI
    

提交回复
热议问题