update table2
set oldlogon=t1.newlogon
from table1 t1 inner join database2.dbo.table1 t21 on t1.id=t21.id
where oldlogon=t12.oldlogon
set oldlogon=t1.newlogon
from table1 t1 inner join database2.dbo.table1 t21 on t1.id=t21.id
where oldlogon=t12.oldlogon