zoukankan      html  css  js  c++  java
  • SQL-Server collation, what is it and how to change db/column collation

    The thing about collations is that although database have it's own collation, every table, and every column can have it's own collation. If not specified it takes the default of it's parent object, but can be different.

    When you change collation of database, it will be new default for all new tables and columns, but it doesn't change the collation of existing objects inside database. You have to go and change manually the collation of every table and column.

    Luckily there are scripts available on the internet that can do the job. I am not going to recommend any as I haven't tried them but here are few links:

    http://www.codeproject.com/Articles/302405/The-Easy-way-of-changing-Collation-of-all-Database

    Update Collation of all fields in database on the fly

    http://www.sqlservercentral.com/Forums/Topic820675-146-1.aspx

    If you need to have different collation on two objects or can't change collations - you can still JOIN between them using COLLATE command, and choosing the collation you want for join.

    SELECT * FROM A JOIN B ON A.Text = B.Text COLLATE Latin1_General_CI_AS 

    or using default database collation:

    SELECT * FROM A JOIN B ON A.Text = B.Text COLLATE DATABASE_DEFAULT

     

     
    BUT when I executing
    ALTER DATABASE [optimiser] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    ALTER DATABASE [optimiser] COLLATE SQL_Latin1_General_CP1_CI_AS
    ALTER DATABASE [optimiser] SET MULTI_USER
    i got below error: 
    Msg 1205, Level 13, State 68, Line 1
    Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
    Msg 5069, Level 16, State 1, Line 1
    ALTER DATABASE statement failed.
     
    the solution is:
         in db configuration manager, disable TCP/IP protocol or something similar to cut down all connections, then try the script again.
  • 相关阅读:
    Service、chkconfig命令
    mongoDB 入门
    HTTP 缓存
    MIME类型记录
    CSS3 动画 思维导图
    部署Seafile服务
    AngularJS 学习笔记
    Bootstrap3 学习笔记
    CSS 弹性盒
    传送门(portal)
  • 原文地址:https://www.cnblogs.com/scottgu/p/6514694.html
Copyright © 2011-2022 走看看