Unix Technical Forum

sql Cannot resolve collation conflict equals - comparing rows and fileds between Table1 and View1

This is a discussion on sql Cannot resolve collation conflict equals - comparing rows and fileds between Table1 and View1 within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello, I currently have Table1 and View1. View1 is a query from 2 or 3 tables that works fine ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:22 PM
Yas
 
Posts: n/a
Default sql Cannot resolve collation conflict equals - comparing rows and fileds between Table1 and View1

Hello,

I currently have Table1 and View1.

View1 is a query from 2 or 3 tables that works fine on its own.

However in my current query if I try to use it...something like...

SELECT a.col1, a.col2, a.col3, b.col1, b.col2, b.col3
FROM View1 a JOIN Table1 b on a.col1 = b.col1
WHERE a.col2 <> b.col2 OR a.col3 <> b.col3


It throws an error "Server: Msg 446, Level 16, State 9, Line 1 Cannot
resolve collation conflict for not equal to operation."

Clearly I need to use collation between Table1 and View1, But I dont
know where I need to use "COLLATE SQL_Latin1_General_CP850_CI_AI" and
how? this is the collation set on Table1.


Thank you!

Yas

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:22 PM
Erland Sommarskog
 
Posts: n/a
Default Re: sql Cannot resolve collation conflict equals - comparing rows and fileds between Table1 and View1

Yas (yasar1@gmail.com) writes:
> I currently have Table1 and View1.
>
> View1 is a query from 2 or 3 tables that works fine on its own.
>
> However in my current query if I try to use it...something like...
>
> SELECT a.col1, a.col2, a.col3, b.col1, b.col2, b.col3
> FROM View1 a JOIN Table1 b on a.col1 = b.col1
> WHERE a.col2 <> b.col2 OR a.col3 <> b.col3
>
>
> It throws an error "Server: Msg 446, Level 16, State 9, Line 1 Cannot
> resolve collation conflict for not equal to operation."
>
> Clearly I need to use collation between Table1 and View1, But I dont
> know where I need to use "COLLATE SQL_Latin1_General_CP850_CI_AI" and
> how? this is the collation set on Table1.


For instance:

SELECT a.col1, a.col2, a.col3, b.col1, b.col2, b.col3
FROM View1 a
JOIN Table1 b on a.col1 COLLATE SQL_Latin1_General_CP850_CI_AI = b.col1
WHERE a.col2 COLLATE SQL_Latin1_General_CP850_CI_AI <> b.col2
OR a.col3 COLLATE SQL_Latin1_General_CP850_CI_AI <> b.col3

You only need the COLLATE clause for character columns, so if any of these
are for instance int, you can skip the COLLATE clause for these.

What collation are the other columns? If they are of a different code
page than CP850 and you are using varchar, there could be unepxected results
due to character conversions.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com