---- Buildings - AFTER UPDATE,DELETE ----
CREATE TRIGGER AfterBuildingsUpdate ON [dbo].[Buildings] 
AFTER UPDATE,DELETE
AS
  SET NOCOUNT ON
  if (SELECT Count(AddressID) FROM DELETED) > 0
    DELETE FROM AddressBaseParts WHERE 
      AddressID in (select AddressID from DELETED)
      AND ((select count(AddressID) from inserted) = 0 OR   
      AddressID not in (select AddressID from INSERTED))  
  SET NOCOUNT OFF