В триггере таблица
deleted содержит удаляемые
строки (повторяю "сроки", а не одну строку). Например:
CREATE TRIGGER PersonDelete ON [Person] FOR DELETE AS
BEGIN
SET NOCOUNT ON
-- [dbo].[Variant]
DELETE FROM Variant WHERE (Variant.Kind = 'P') AND (Variant.[Object] IN ( SELECT ID FROM deleted))
-- [dbo].[Internet]
DELETE FROM Internet WHERE (Internet.Kind = 'P') AND (Internet.[Object] IN ( SELECT ID FROM deleted))
END
--
GO
Или соединение, например:
CREATE TRIGGER AttributeValueUpdateDelete ON FilmAttributeValue FOR UPDATE, DELETE AS
BEGIN
SET NOCOUNT ON
UPDATE FilmAttributeGroup
SET Uses = (SELECT COUNT(*) FROM FilmAttributeValue WHERE ([Group] = deleted.[Group]))
FROM FilmAttributeGroup
INNER JOIN deleted ON FilmAttributeGroup.ID = deleted.[Group]
END
--
GO