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)
 Case statement error

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2009-06-08 : 18:48:18
---keep getting error on the = before case.
Any ideas.

update c
set phone_id = left(isnull(b.ipPhone, c.phone_id), 25),
phone_ext_cd =
case
when len(b.telephoneNumber) = '12' then phone_ext_cd = ''
when len(b.telephoneNumber) = '6' then phone_ext_cd = left(isnull(b.telephoneNumber, c.phone_ext_cd), 6)
end
,
modified_by = 'SCRIPT'
from empl a
inner join dbo.adempl b
on a.email_id = b.mail
inner join empl_phone c
on a.empl_id = c.empl_id
where a.s_empl_status_cd = 'ACT'
and a.contractor_fl = 'N'
and c.phone_type_dc = 'WORK'

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-06-08 : 18:51:01
case
when len(b.telephoneNumber) = '12' then ''
when len(b.telephoneNumber) = '6' then left(isnull(b.telephoneNumber, c.phone_ext_cd), 6)
end

Jim
Go to Top of Page
   

- Advertisement -