ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 255.8k

How to write this statement with another way best without re

Mar 23 2020 12:50 PM
I work on SQL server 2012 i update two fields depend on every team id
  1. update dpt  
  2. set Package=case when tmp.TeamId=1 then 1 end ,  
  3. PackageDate=case when tmp.TeamId=1 then getdate() end ,  
  4. Parametric=case when tmp.TeamId=2 then 2 end,  
  5. ParametricDate=case when tmp.TeamId=2 then getdate() end ,  
  6. Scribing=case when tmp.TeamId=3 then 3 end,  
  7. ScribingDate=case when tmp.TeamId=3 then getdate() end ,  
  8. Lifecycle=case when tmp.TeamId=4 then 4 end,  
  9. LifecycleDate=case when tmp.TeamId=4 then getdate() end  
  10. from PCN.DocumentPartTeams dpt inner join #Temp tmp on dpt.PartID=tmp.PartID and dpt.DocumentID=tmp.DocumentID  
  11. and tmp.Status is null  
I need to rewrite statement with another way best as following
because i repeat same condition multi time
i need to write it one time only meaning as below
case when teamid=2
then date=getdata and parametric=2
so how to do that please ?