---- Строительное_сооружение - AFTER UPDATE,DELETE ----
-- удаляем строительную часть строительного сооружения
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AfterСтроительное_сооружениеUpdate]') and xtype = N'TR')
drop trigger [dbo].[AfterСтроительное_сооружениеUpdate]
GO
CREATE TRIGGER AfterСтроительное_сооружениеUpdate ON [dbo].[Строительное_сооружение] 
AFTER UPDATE,DELETE
AS
  if (SELECT Count(ConstructionID) FROM DELETED) > 0
    DELETE FROM Constructions WHERE 
      ConstructionID in (select ConstructionID from DELETED)
      AND ((select count(ConstructionID) from inserted) = 0 OR   
      ConstructionID not in (select ConstructionID from INSERTED))  
