Database Collation problem when comparing two databases












1














I have changed the collation of test database using the follwoing query:



USE master;  
GO
ALTER DATABASE test
COLLATE SQL_Latin1_General_CP1_CI_AI ;
GO

--Verify the collation setting.
SELECT name, collation_name
FROM sys.databases
WHERE name = N'test';
GO


Now when I want to compare a columns of test database against test2 database, I receive the following error:




Cannot resolve the collation conflict between
"SQL_Latin1_General_CP1_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in
the equal to operation.




I have checked that both databases has SQL_Latin1_General_CP1_CI_AI collation in :



Management studio > Database > properties > options > collation. 


Is there another option rather than the database itself (e.g. schema) which still holds the old collation?










share|improve this question









New contributor




Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1














    I have changed the collation of test database using the follwoing query:



    USE master;  
    GO
    ALTER DATABASE test
    COLLATE SQL_Latin1_General_CP1_CI_AI ;
    GO

    --Verify the collation setting.
    SELECT name, collation_name
    FROM sys.databases
    WHERE name = N'test';
    GO


    Now when I want to compare a columns of test database against test2 database, I receive the following error:




    Cannot resolve the collation conflict between
    "SQL_Latin1_General_CP1_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in
    the equal to operation.




    I have checked that both databases has SQL_Latin1_General_CP1_CI_AI collation in :



    Management studio > Database > properties > options > collation. 


    Is there another option rather than the database itself (e.g. schema) which still holds the old collation?










    share|improve this question









    New contributor




    Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1







      I have changed the collation of test database using the follwoing query:



      USE master;  
      GO
      ALTER DATABASE test
      COLLATE SQL_Latin1_General_CP1_CI_AI ;
      GO

      --Verify the collation setting.
      SELECT name, collation_name
      FROM sys.databases
      WHERE name = N'test';
      GO


      Now when I want to compare a columns of test database against test2 database, I receive the following error:




      Cannot resolve the collation conflict between
      "SQL_Latin1_General_CP1_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in
      the equal to operation.




      I have checked that both databases has SQL_Latin1_General_CP1_CI_AI collation in :



      Management studio > Database > properties > options > collation. 


      Is there another option rather than the database itself (e.g. schema) which still holds the old collation?










      share|improve this question









      New contributor




      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have changed the collation of test database using the follwoing query:



      USE master;  
      GO
      ALTER DATABASE test
      COLLATE SQL_Latin1_General_CP1_CI_AI ;
      GO

      --Verify the collation setting.
      SELECT name, collation_name
      FROM sys.databases
      WHERE name = N'test';
      GO


      Now when I want to compare a columns of test database against test2 database, I receive the following error:




      Cannot resolve the collation conflict between
      "SQL_Latin1_General_CP1_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in
      the equal to operation.




      I have checked that both databases has SQL_Latin1_General_CP1_CI_AI collation in :



      Management studio > Database > properties > options > collation. 


      Is there another option rather than the database itself (e.g. schema) which still holds the old collation?







      sql-server collation






      share|improve this question









      New contributor




      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 hours ago









      mustaccio

      8,95162136




      8,95162136






      New contributor




      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      Ali Sheikhpour

      1285




      1285




      New contributor




      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Ali Sheikhpour is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          1














          First: Collations for columns are stored per-each column.



          Second: The ALTER DATABASE ... COLLATE ... statement changes only the default collation of the database itself. It does not change the collation of any existing columns within the database. This change affects:




          • database-level meta-data (mostly names of database-level objects: tables, columns, procedures, functions, triggers, indexes, users, views, constraints, etc, etc)

          • new string columns that do not specify a COLLATE clause. New via:


            • CREATE TABLE ...

            • ALTER TABLE ... ADD


            • DECLARE @TableVariable TABLE ... (these default to the database's collation, not [tempdb]'s collation)



          • new or altered columns that do specify COLLATE using DATABASE_DEFAULT

          • string literals and variables


          For an in-depth look at changing database-level (and even instance-level) collations, please see my post:



          Changing the Collation of the Instance, the Databases, and All Columns in All User Databases: What Could Possibly Go Wrong?



          For more info on working with collations in general, please visit: Collations Info






          share|improve this answer































            0














            Check the collation on the columns you are comparing, you'll probably find out that on test the columns are still in SQL_Latin1_General_CP1_CI_AS. Try declaring collation explicitly in your comparison and see if it helps.



            Also, are you storing something in tempdb? If your instance is based on one or the other you could have this issue.






            share|improve this answer








            New contributor




            Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.


















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "182"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });






              Ali Sheikhpour is a new contributor. Be nice, and check out our Code of Conduct.










              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225682%2fdatabase-collation-problem-when-comparing-two-databases%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              First: Collations for columns are stored per-each column.



              Second: The ALTER DATABASE ... COLLATE ... statement changes only the default collation of the database itself. It does not change the collation of any existing columns within the database. This change affects:




              • database-level meta-data (mostly names of database-level objects: tables, columns, procedures, functions, triggers, indexes, users, views, constraints, etc, etc)

              • new string columns that do not specify a COLLATE clause. New via:


                • CREATE TABLE ...

                • ALTER TABLE ... ADD


                • DECLARE @TableVariable TABLE ... (these default to the database's collation, not [tempdb]'s collation)



              • new or altered columns that do specify COLLATE using DATABASE_DEFAULT

              • string literals and variables


              For an in-depth look at changing database-level (and even instance-level) collations, please see my post:



              Changing the Collation of the Instance, the Databases, and All Columns in All User Databases: What Could Possibly Go Wrong?



              For more info on working with collations in general, please visit: Collations Info






              share|improve this answer




























                1














                First: Collations for columns are stored per-each column.



                Second: The ALTER DATABASE ... COLLATE ... statement changes only the default collation of the database itself. It does not change the collation of any existing columns within the database. This change affects:




                • database-level meta-data (mostly names of database-level objects: tables, columns, procedures, functions, triggers, indexes, users, views, constraints, etc, etc)

                • new string columns that do not specify a COLLATE clause. New via:


                  • CREATE TABLE ...

                  • ALTER TABLE ... ADD


                  • DECLARE @TableVariable TABLE ... (these default to the database's collation, not [tempdb]'s collation)



                • new or altered columns that do specify COLLATE using DATABASE_DEFAULT

                • string literals and variables


                For an in-depth look at changing database-level (and even instance-level) collations, please see my post:



                Changing the Collation of the Instance, the Databases, and All Columns in All User Databases: What Could Possibly Go Wrong?



                For more info on working with collations in general, please visit: Collations Info






                share|improve this answer


























                  1












                  1








                  1






                  First: Collations for columns are stored per-each column.



                  Second: The ALTER DATABASE ... COLLATE ... statement changes only the default collation of the database itself. It does not change the collation of any existing columns within the database. This change affects:




                  • database-level meta-data (mostly names of database-level objects: tables, columns, procedures, functions, triggers, indexes, users, views, constraints, etc, etc)

                  • new string columns that do not specify a COLLATE clause. New via:


                    • CREATE TABLE ...

                    • ALTER TABLE ... ADD


                    • DECLARE @TableVariable TABLE ... (these default to the database's collation, not [tempdb]'s collation)



                  • new or altered columns that do specify COLLATE using DATABASE_DEFAULT

                  • string literals and variables


                  For an in-depth look at changing database-level (and even instance-level) collations, please see my post:



                  Changing the Collation of the Instance, the Databases, and All Columns in All User Databases: What Could Possibly Go Wrong?



                  For more info on working with collations in general, please visit: Collations Info






                  share|improve this answer














                  First: Collations for columns are stored per-each column.



                  Second: The ALTER DATABASE ... COLLATE ... statement changes only the default collation of the database itself. It does not change the collation of any existing columns within the database. This change affects:




                  • database-level meta-data (mostly names of database-level objects: tables, columns, procedures, functions, triggers, indexes, users, views, constraints, etc, etc)

                  • new string columns that do not specify a COLLATE clause. New via:


                    • CREATE TABLE ...

                    • ALTER TABLE ... ADD


                    • DECLARE @TableVariable TABLE ... (these default to the database's collation, not [tempdb]'s collation)



                  • new or altered columns that do specify COLLATE using DATABASE_DEFAULT

                  • string literals and variables


                  For an in-depth look at changing database-level (and even instance-level) collations, please see my post:



                  Changing the Collation of the Instance, the Databases, and All Columns in All User Databases: What Could Possibly Go Wrong?



                  For more info on working with collations in general, please visit: Collations Info







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago

























                  answered 1 hour ago









                  Solomon Rutzky

                  47.3k579171




                  47.3k579171

























                      0














                      Check the collation on the columns you are comparing, you'll probably find out that on test the columns are still in SQL_Latin1_General_CP1_CI_AS. Try declaring collation explicitly in your comparison and see if it helps.



                      Also, are you storing something in tempdb? If your instance is based on one or the other you could have this issue.






                      share|improve this answer








                      New contributor




                      Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.























                        0














                        Check the collation on the columns you are comparing, you'll probably find out that on test the columns are still in SQL_Latin1_General_CP1_CI_AS. Try declaring collation explicitly in your comparison and see if it helps.



                        Also, are you storing something in tempdb? If your instance is based on one or the other you could have this issue.






                        share|improve this answer








                        New contributor




                        Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          0












                          0








                          0






                          Check the collation on the columns you are comparing, you'll probably find out that on test the columns are still in SQL_Latin1_General_CP1_CI_AS. Try declaring collation explicitly in your comparison and see if it helps.



                          Also, are you storing something in tempdb? If your instance is based on one or the other you could have this issue.






                          share|improve this answer








                          New contributor




                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          Check the collation on the columns you are comparing, you'll probably find out that on test the columns are still in SQL_Latin1_General_CP1_CI_AS. Try declaring collation explicitly in your comparison and see if it helps.



                          Also, are you storing something in tempdb? If your instance is based on one or the other you could have this issue.







                          share|improve this answer








                          New contributor




                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 2 hours ago









                          Gabriele Massari

                          83




                          83




                          New contributor




                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Gabriele Massari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






















                              Ali Sheikhpour is a new contributor. Be nice, and check out our Code of Conduct.










                              draft saved

                              draft discarded


















                              Ali Sheikhpour is a new contributor. Be nice, and check out our Code of Conduct.













                              Ali Sheikhpour is a new contributor. Be nice, and check out our Code of Conduct.












                              Ali Sheikhpour is a new contributor. Be nice, and check out our Code of Conduct.
















                              Thanks for contributing an answer to Database Administrators Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225682%2fdatabase-collation-problem-when-comparing-two-databases%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Accessing regular linux commands in Huawei's Dopra Linux

                              Can't connect RFCOMM socket: Host is down

                              Kernel panic - not syncing: Fatal Exception in Interrupt