USP_EMAIL_DELETE_GET_MARKED
Definition
Copy
CREATE procedure dbo.USP_EMAIL_DELETE_GET_MARKED
as
begin
set nocount on;
-- The min date makes sure there has been time to respond, if the email has been sent.
-- put in descending order to make sure children are deleted before parent.
-- get the child records
select child.ID as ID from dbo.Email child
inner join dbo.Email parent on child.ParentEmailID = parent.ID where
parent.Deleted = 1
union
-- get the parent
select ID from dbo.email where Deleted=1
order by ID;
end