Why if I write a trigger to delete table T1
Table t1
id id_employeeFrom id_employeeTo 1 1 2 1 1 3 1 2 4 1 3 5 1 4 10 1 10 11 Trigger on table T1
CREATE TRIGGER [TR_MyTrigger] ON T1 AFTER DELETE AS BEGIN DECLARE @id BIGINT SELECT TOP 1 @id = id FROM DELETED DELETE FROM T1 WHERE T1.id = @id AND T1.id_employeeFrom IN (SELECT id_employeeTo FROM DELETED) END request
DELETE FROM T1 WHERE id = 1 ` `AND id_employeeTo = 2 the trigger is triggered only once, that is, the table remains:
id id_employeeFrom id_employeeTo 1 1 3 1 3 5 1 4 10 1 10 11 I need to stay
id id_employeeFrom id_employeeTo 1 1 3 1 3 5 Why is this happening? In general, I can't pull records across the hierarchy, starting with id_employeeTo ...