INSERT INTO {databaseOwner}{objectQualifier}DMX_LogTypes 
 ([LogTypeKey], [PortalId], [ResourceFile], [AttachFile], [CustomSend], [NotifyApprovers], [NotifyEditors], [NotifyOwner], [NotifySelf], [NotifySubscribers], [NotifyAudit]) 
SELECT 
 N'HardDelete', p.PortalId, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, 1
FROM {databaseOwner}{objectQualifier}Portals p
WHERE NOT EXISTS
 (SELECT * FROM {databaseOwner}{objectQualifier}DMX_LogTypes lt2 WHERE lt2.PortalId=p.PortalId AND lt2.LogTypeKey='HardDelete')
GO


