SQL Server - is there a way to mass resolve collation conflicts

后端 未结 3 1907
温柔的废话
温柔的废话 2021-01-06 18:48

We have a situation where the collation of databases, tables, and some columns are different between our dev and production SQL Servers, and it\'s wreaking havoc on developm

相关标签:
3条回答
  • 2021-01-06 19:21

    Your first step is probably deciding on your standard for what collation you should be using. If you are going to be supporting multiple collations due to international requirements for your application then decide which ones you will support and how you plan to test for all collations.

    The first step here is deciding operationally what you'll be doing, not the technical solution. Once you've done that, you're going to have to bite the bullet and go through all of your tables, stored procedures, etc. and get all of them in sync on ALL of your servers and in any source code that you have in your source control system. Ideally your queries will work without referring to any collation or doing any conversions to wrestle things into working.

    To help you find all of your collation issues, you can start looking at this in all of your databases:

    SELECT * FROM INFORMATION_SCHEMA.COLUMNS
    
    0 讨论(0)
  • 2021-01-06 19:21

    I have had great success using this tool http://www.codeproject.com/KB/database/ChangeCollation.aspx

    0 讨论(0)
  • 2021-01-06 19:41

    Generally, use "COLLATE DATABASE_DEFAULT" on temp table, table variables etc

    Collation conflicts usually happen you have server vs database collation conflicts, server in this case being tempdb.

    Frankly, I would make an effort to align your collations and have them all one per database.

    If you have mix and match across servers, databases and columns then there is no magic bullet. You could start by looking for all COLLATE clauses in code (see above) followed by ensuring all columns have collation removed....

    0 讨论(0)
提交回复
热议问题