I want to add a condition in the joining columns part of the merge statement like this :
Merge dbo.tblDest as target
using
(select ...) as source
on target.EmpID =  source.EmpID
and target.AwardID = source.AwardID  --this second condition I want to add only if the source.AwardID is not null. How to do that pls advise.
something like this -
on target.tblEmpID =  source.tblEmpID
and case when source.tblAwardID is not null then target.tblAwardID = source.tblAwardID end --but this syntax doesnt work .
 
- This topic was modified 4 months, 2 weeks ago by SQL Bee.