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)
 Confused join

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2011-02-02 : 11:04:46
Hi,

I have the following query

if not exists (
select a.period
from a inner join b
on a.period = b.period or a.period = b.period2

thing is the value in a.period is either aug or 1 and table b has lookup for all months and their values.

but when i run this query it says
'Conversion failed when converting the varchar value 'Aug' to data type int.'

Any help? thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-02 : 11:24:57
...
on
CASE
WHEN a.period = 'Jan' then 1
WHEN a.period = 'Feb' then 2
...
END = b.period
OR
CASE
WHEN a.period = 'Jan' then 1
WHEN a.period = 'Feb' then 2
...
END = b.period2



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -