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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SELECT CASE?

Author  Topic 

BradenDCOM
Starting Member

1 Post

Posted - 2010-04-09 : 11:05:35
Hi there i'm getting this error when i execute:

Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

here's my code. I'm guessing it has something to conversion to varchar. I tried casting the case but i dont think that works?
Any help would be much appreciated.

SELECT 'ActivationButton/Area' =
CASE
WHEN fk_ActivationButtonID IS NOT NULL THEN AB.Name
WHEN fk_AreaID IS NOT NULL THEN A.Name
END
FROM PrimaryTour PT
LEFT JOIN Area A ON A.AreaID = PT.fk_AreaID
LEFT JOIN ActivationButton AB ON AB.ActivationButtonID = fk_ActivationButtonID

Regards,
Braden

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-09 : 11:38:40
It looks like Area.Name and ActivationButton.Name use conflicting collations.

Try this:

SELECT 'ActivationButton/Area' =
CASE
WHEN fk_ActivationButtonID IS NOT NULL THEN CAST(AB.Name As VARCHAR(width))
COLLATE database_default
WHEN fk_AreaID IS NOT NULL THEN CAST(A.Name As VARCHAR(width))
COLLATE database_default
END
FROM PrimaryTour PT
LEFT JOIN Area A ON A.AreaID = PT.fk_AreaID
LEFT JOIN ActivationButton AB ON AB.ActivationButtonID = fk_ActivationButtonID


Replace "width" with the appropriate values for your data.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page
   

- Advertisement -