devicelimit = 0 CREATE TRIGGER tg_users_delete ON users FOR DELETE AS BEGIN DELETE FROM user_user WHERE manageduserid IN (SELECT deleted.id FROM deleted) END CREATE TRIGGER tg_groups_delete ON groups FOR DELETE AS BEGIN UPDATE groups SET groupid = NULL WHERE groupid IN (SELECT deleted.id FROM deleted) END