Cannot Resolve Collation Conflict

前端 未结 1 498
南方客
南方客 2020-12-02 20:06

I have moved one of our databases (DB1) from SQL Server 2008 to 2012 and when I run the stored procedures I get the following error

Cannot resolve the

相关标签:
1条回答
  • 2020-12-02 20:33

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

    When you change collation of the database, it will be the new default for all new tables and columns, but it doesn't change the collation of existing objects inside the 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
    
    0 讨论(0)
提交回复
热议问题