Cannot resolve collation conflict in Union select

Posted by phenevo on Stack Overflow See other posts from Stack Overflow or by phenevo
Published on 2010-04-20T08:36:38Z Indexed on 2010/04/20 8:53 UTC
Read the original article Hit count: 205

Filed under:
|

Hi,

I've got tqo queries:

First doesn't work:

select hotels.TargetCode as TargetCode from hotels
union all 
select DuplicatedObjects.duplicatetargetCode as TargetCode from DuplicatedObjects where DuplicatedObjects.objectType=4

because I get error:

Cannot resolve collation conflict for column 1 in SELECT statement.

Second works:

select hotels.Code from hotels where hotels.targetcode is not null 
union all 
select DuplicatedObjects.duplicatetargetCode as Code from DuplicatedObjects where DuplicatedObjects.objectType=4 

Structure:

Hotels.Code -PK nvarchar(40)
Hotels.TargetCode - nvarchar(100)

DuplicatedObjects.duplicatetargetCode PK nvarchar(100)

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005