我正在寻找一种在 SQL Server 中将这两个语句组合成一个的方法。我尝试搜索“条件连接”,但没有看到这个确切的例子感谢您的帮助。
update
employees
set
employees.RefID = ed.RefID
from
#tmpEmployees employees
inner join EmployeeDirectory ed on ed.ABC = employees.ABC
where
( nullif(ed.ABC, '') is not null and nullif(employees.ABC, '') is not null)
update
employees
set
employees.RefID = ed.RefID
from
#tmpEmployees employees
inner join EmployeeDirectory ed on ed.DEF = employees.DEF
where
( nullif(ed.DEF, '') is not null and nullif(employees.DEF, '') is not null)