Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 collation conflict

Author  Topic 

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2010-02-11 : 10:39:17
Hi friends

Hope you are all well?
I need help with this error message:
cannot resolve collation conflict for equal to operation.
This occurs for the two delete commands at the bottom of the stored procedure but I don't understand what is causing this.



declare @tabledupe table(lrid varchar)
declare @tablerepeat table(lrid varchar)

INSERT INTO @tabledupe(lrid)
SELECT tb_lrproperties.prop_branchref FROM tb_properties left join
tb_lrproperties On tb_properties.prop_postcode = tb_lrproperties.prop_postcode
WHERE
tb_lrproperties.prop_name = tb_properties.prop_name


insert into @tablerepeat(lrid)
SELECT prop_branchref
FROM tb_lrproperties
GROUP BY prop_branchref
HAVING ( COUNT(prop_branchref) > 1
)

select lrid from @tabledupe


DELETE tb_lrproperties where prop_branchref in (select lrid from @tabledupe)
DELETE tb_lrproperties where prop_branchref in (select lrid from @tablerepeat)


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 10:42:13
quote:
Originally posted by godspeedba

Hi friends

Hope you are all well?
I need help with this error message:
cannot resolve collation conflict for equal to operation.
This occurs for the two delete commands at the bottom of the stored procedure but I don't understand what is causing this.



declare @tabledupe table(lrid varchar)
declare @tablerepeat table(lrid varchar)

INSERT INTO @tabledupe(lrid)
SELECT tb_lrproperties.prop_branchref FROM tb_properties left join
tb_lrproperties On tb_properties.prop_postcode COLLATE DATABASE_DEFAULT= tb_lrproperties.prop_postcode COLLATE DATABASE_DEFAULT
WHERE
tb_lrproperties.prop_name COLLATE DATABASE_DEFAULT= tb_properties.prop_name COLLATE DATABASE_DEFAULT


insert into @tablerepeat(lrid)
SELECT prop_branchref
FROM tb_lrproperties
GROUP BY prop_branchref
HAVING ( COUNT(prop_branchref) > 1
)

select lrid from @tabledupe


DELETE tb_lrproperties where prop_branchref in (select lrid from @tabledupe)
DELETE tb_lrproperties where prop_branchref in (select lrid from @tablerepeat)





modify like above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2010-02-11 : 10:46:05
I still get the same message :(
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 10:49:20
what are the other character fields that are used in comparison. add the same clause to other comparison statements too

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2010-02-11 : 10:56:16
Instead of putting the data into a temp table I used the delete from in front the sections that put data into the temptable.
These seems to have solved it. Thanks for your time Visakh
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-11 : 12:37:05
Whenever we create a #TEMP or @TableVar table we explicitly define the Collation on any Varchar/Char/Text column. Thus if TEMPDB (i.e. Server Default) collation is different to the Current Database we don't get collation errors when we reference the columns in the Temp table.

Bit of a PITA, but it does make your application collation-neutral if it is moved to a server with a different collation.

Only time we need to be careful is when comparing columns between databases which have different collations (data import from another application's DB, for example)
Go to Top of Page
   

- Advertisement -