Click here to Skip to main content
15,888,208 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I'm using a SQL Server 2000 DB which interacts with an SQL Server 2005 DB on a remote machine via linked server.
Every thing works fine, except updating some columns in the source-tables on the remote machine:"Cannot resolve collation conflict for equal to operation" is the message I always get.

I'm working with temporary tables (#TempTbl e.g.) where I store results when I query the source tables and I want to use the same results to update the source tables "read by client"-column - but it always fails.

Ialso changed the collation locally (#TempTbl) to the remote DBs collation before comparing it but it does not help.

Can anybody tell me what I'm doing wrong or is this issue related to the #TempTbl? Has anybody an alternative solution to my problem?

Thanks in advance.

d-as_2009
Posted

A collation defines the code page sort order for unicode data types and code page characters. The error you get tells you that the definition between the two columns doesn't match so you need to explicitly specify what collation should be used, like this:
SQL
SELECT id
  FROM TmpTable1
  INNER JOIN TmpTable2
  WHERE TmpTable1.name COLLATE DATABASE_DEFAULT = TmpTable2.name COLLATE DATABASE_DEFAULT 


Good luck!
 
Share this answer
 
Thanks E.F. Nijboer for your post. The solution you provide I 've already checked - with no success (... "I also changed the collation locally (#TempTbl) to the remote DBs collation" ...).

But I probably found another way to fix this problem (thanks to http://onlytalkingsense.wordpress.com):

..."The easiest way to fix this is to let SQL Server create the temp table for you via a SELECT INTO statement:

SELECT name, firstName
FROM somewhere
INTO #MyTempTable

The temp table will still be created in tempdb, but it’s fields will take the collation from their source (in this case, the fields in the <somewhere> table." ...
 
Share this answer
 
Comments
d-as_2010 22-Jan-12 5:24am    
The way above works fine if I read from the remote machine but it also fails, when I try to update some records in the source-tables on the remote machine.
Before updating certain rows some conditions have to match, e.g. I've to compare several nvarchar-fields within this records with my local copies since the same record sometimes exits many times with only one field different.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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