---- Работа - FOR DELETE ----
  -- при удалении из Работы удаляются все её подработы
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OnWorkDelete]') and xtype = N'TR')
drop trigger [dbo].[OnWorkDelete]
GO
CREATE TRIGGER OnWorkDelete ON [dbo].[Работа] 
FOR DELETE 
AS
  if (SELECT Count(*) FROM DELETED) > 0 DELETE FROM Работа WHERE Код_работы_владельца IN (SELECT Код_работы FROM DELETED)
