create trigger TriggerName on Table2 for update,insert
as
if exists(select * from inserted where E=2)
  if exists(select * from Table1 where A=(select A from inserted))
      update Table1 set B=Inserted.B from Table1,Inserted where Table1.A=Inserted.A
  else
      Insert Table1 select A,B,C,D from Inserted