How to handle Collation errors when joining 2 tables of different databases

  • Hi All,

    I have 2 databases with different collations, when i try to join them it shows me the collation error please help in soloving the error.

    Thanks in advance

  • can you post the code which you are using, so some one can have a look and suggest some option

  • My Query is

    Select B.location, A.loccvg from [db1].[dbo].[dummy1] A

    inner join [db1].[dbo].[dummy1] B on A.LOCATION=B.LOCATION

  • At the end of your statement add 'COLLATE' followed by the collation name that you want the results in.

  • Thanks for you reply I have tried this thing it works.....but I am looking for something much more smarter way to avoid it as, I have many queries of these types and we have many databases on diffrent locations

  • I don't think there is a way other than converting the databases to be in the same collation, collation is a very annoying thing when you get into it for cross collation queries and for converting databases.

  • you can ignore this when creating a linked server, there is a collation option , you can turn it off or on , if you are using 2005, you can change collation of a column, this will be more complex and annoying when you write SQL 😀

  • You could just use COLLATE DATABASE_DEFAULT.

    At least you would not need to know what collation setting you are playing with. You would still need to put this into each of the queries that have the problem

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply