Sie würden so etwas brauchen - ein Set-basiertes Lösung, die das in einem UPDATE berücksichtigt -Anweisung aktualisieren Sie möglicherweise mehrere Zeilen auf einmal, und daher muss Ihr Trigger auch mit mehreren Zeilen im Inserted umgehen und Deleted Tabellen.
CREATE TRIGGER [dbo].[updateUserId]
ON [dbo].[User_TB]
FOR UPDATE
AS
-- update the "Break" table - find the rows based on the *old* User_Id
-- from the "Deleted" pseudo table, and set it to the *new* User_Id
-- from the "Inserted" pseudo table
SET User_Id = i.User_Id
FROM Inserted i
INNER JOIN Deleted d ON i.TID = d.TID
WHERE
Break_TB.User_Id = d.User_Id
-- update the "Log" table - find the rows based on the *old* User_Id
-- from the "Deleted" pseudo table, and set it to the *new* User_Id
-- from the "Inserted" pseudo table
UPDATE Break_TB
SET User_Id = i.User_Id
FROM Inserted i
INNER JOIN Deleted d ON i.TID = d.TID
WHERE
Break_TB.User_Id = d.User_Id
Dieser Code annimmt dass die TID Spalte in User_TB Tabelle ist der Primärschlüssel die bei Updates gleich bleibt (damit ich die "alten" Werte aus der Deleted zusammenfügen kann Pseudotabelle mit den "neuen" Werten nach dem Update, gespeichert im Inserted Pseudotabelle)