You are missing FROM Inserted in an UPDATE - try the following:
CREATE TRIGGER contacts_f_tr ON contacts_f AFTER UPDATE AS BEGIN --- ---Update repository data --- IF UPDATE (mail) BEGIN UPDATE mails SET contact = inserted.name, mail = inserted.mail FROM Inserted <<==== add this line here! WHERE mails.idcontact IN (SELECT mail FROM deleted) AND mails.tablecontact = 2 END END
Also - after including this pseudo-table, you should somehow refer to it / join something else ...
Update: you may need to add an additional WHERE if you add the Inserted pseudo-table to the equation - which exactly depends on your requirements, which I donβt know, but it could be something like
WHERE mails.idcontact IN (SELECT mail FROM deleted) AND mails.tablecontact = 2 AND mails.MailId = Inserted.MailId
or something like that (to avoid the Cartesian product in your UPDATE ).
marc_s
source share