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

I am encountering a (weird?) problem with a collation conflict (MSSQL2008).

A simplified example of my query:
SQL
SELECT X.*
      ,Y.Field3
FROM (SELECT Field1
            ,Field2
      FROM TABLE1) X
      LEFT OUTER JOIN TABLE2 Y ON X.Field1 = Y.Field1


This works nicely (with the X.*), but when I specifically write out the columns of table X:

SQL
SELECT X.Field1
      ,X.Field2
      ,Y.Field3
FROM (SELECT Field1
            ,Field2
      FROM TABLE1) X
      LEFT OUTER JOIN TABLE2 Y ON X.Field1 = Y.Field1


I get a collation conflict error (Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Finnish_Swedish_CI_AS" in the UNION operation)

Can someone explain to me how specifically naming the columns can cause the conflict, or how using the * "solves" this conflict ?

Regards,
Johan
Posted

1 solution

Replace:
SQL
SELECT X.Field1
      ,X.Field2
      ,Y.Field3
FROM (SELECT Field1
            ,Field2
      FROM TABLE1) X
      LEFT OUTER JOIN TABLE2 Y ON X.Field1 = Y.Field1

with:
SQL
SELECT X.Field1
      ,X.Field2
      ,Y.Field3
FROM TABLE1 AS X LEFT OUTER JOIN TABLE2 Y ON X.Field1 = Y.Field1


You don't need subquery to join two tables!

Secondly, have a look here: Collation Precedence (Transact-SQL)[^] to resolve collation problem/issue.
 
Share this answer
 
v2

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