Click here to Skip to main content
15,886,137 members

Collation Conflict when joining tables in different databases

Minghang asked:

Open original thread
Hello everyone, i have to perform a join between two tables which are on different databases. When working on the development machine everything was working fine until i deployed my database on the clients server. The Clients database is in a different collation...latin1_General_100_CI_AS.While my database is the default latin1_General_CI_AS.
This is the table in my database

SQL
Column Name                     Collation
QuestionGroupCombination	Latin1_General_CI_AS
QuestionGroup	Latin1_General_CI_AS
Company	Latin1_General_CI_AS
DepartmentCode	NULL
Position	Latin1_General_CI_AS
Weightage	NULL
UpdatedBy	Latin1_General_CI_AS



This is the table i want to perform the join on...which is on a different database

SQL
Code	Latin1_General_100_CI_AS
Name	Latin1_General_CI_AS
Dimension Code	Latin1_General_CI_AS




I want to perform join between the Departmentcode and Code columns between the two tables.
Here is my sql query

SQL
select distinct q.QuestionGroupCombination,q.QuestionGroup+'--'+u.Name+'--'+q.Position as CombinedExpr from QuestionGroup as q
                                         inner join [NAV-DB].[dbo].[vw_Department] as u on q.DepartmentCode = u.Code



This query throws the following error:

Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

Also, a thing to note is that the code field in clients table is a varchar(20) type,while the DepartmentCode field is an int field in my table.

i have tried everything suggested in various posts...i tried changing my database collation...i changed the query on the '=' sign as Collate Latin1_General_100_CI_AS on both sides,only one side......then it gives me error saying expression int is invalid for collate clause....i have even changed the datatype of the Field in my table..etc
so, how can i resolve this issue??...Can anyone help...plz

EDIT: The DepartmentCode(varchar(20))...i changed the datatype and is no longer null...it shows Latin1_General_100_CI_AS...but still throws the above error... if it is possible i want to keep the datatype as int...since i have to change a lotta code
Thanks
Tags: SQL, SQL Server

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900