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
 help needed : for update

Author  Topic 

pnasz
Posting Yak Master

101 Posts

Posted - 2010-10-30 : 06:35:30
I have two table one is EmpTimeschedule and another is Attresult

EmpTimeSchedule has following fields

empno
fname
ndcode
fin
fout
thcode
fin1
fin2

attresult has following fields

Empno
entrydate
mfirstin
mfirstout
weekdayname
empin
empout


i want to select fin, fout from EmpTimeSchedule and update the empin,empout of attresult if weekdayname is all day
except thursday
if weekdayname is thursday i want to select fin1 and fin2 from Emptimeschedule and update empin,empout of attresult


please help me

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-10-30 : 09:33:29
update attresult
set empin = case when weekdayname = 'Thursday' then t2.fin2 esle t2.fin end ,
empout = case when weekdayname = 'Thursday' then t2.fout2 esle t2.fout end ,
from attresult t1
join EmpTimeSchedule t2
on t1.empno = t2.empno
....

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -