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



Yas (yasar1@xxxxxxxxx) 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@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: xp_sendmail problems with windows security
    ... I do have a case sensitive collation. ... > b) Right click on the SQL server and choose properties. ... > Each sort order ID has a corresponding SQL Collation name. ... > If the Collation is case sensitive, the query is working as expected. ...
    (microsoft.public.sqlserver.security)
  • RE: Problem with different collation
    ... As my understanding of your question, there is a query that will run on ... 'Cannot resolve collation conflict' error, ... I have to say it is an known issue of the SQL Server 2000. ... Then I add the colation of the linked server table. ...
    (microsoft.public.sqlserver.programming)
  • Re: Collation issue,
    ... If you want to include them in your sorting, ... SQL Server MVP ... Latin_1_General_CI_AS collation, code page 1252. ... tried this query with case sensitve Latin_1_General_CS_AS with the same ...
    (microsoft.public.sqlserver.programming)
  • sql Cannot resolve collation conflict equals - comparing rows and fileds between Table1 and View
    ... 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... ... Clearly I need to use collation between Table1 and View1, ...
    (comp.databases.ms-sqlserver)
  • RE: Advice on Create a SQL Server
    ... Use the default collation. ... domain, and running on a windows domain account, it is better to run under ... Windows Authentication mode. ... to SQL Server using a username/password. ...
    (microsoft.public.sqlserver.setup)