briangriffin
Programmer
I have a recordset in a temp table that contains records like these (in addition to many other records that I want to keep):
I need to delete both these records - anything with a value in the UndoneDateTime field, plus the corresponding original record based on the effective date and the sequence ID. I tried something like this, figured it wouldn't work but it illustrates the idea:
What would be the best way to delete these pairs? TIA.
Code:
Account EffectiveDate SequenceID UndoneDateTime UndoneSequenceID
9999 1/1/2016 13:00 4
9999 1/1/2016 13:00 8 1/2/2016 00:00 4
I need to delete both these records - anything with a value in the UndoneDateTime field, plus the corresponding original record based on the effective date and the sequence ID. I tried something like this, figured it wouldn't work but it illustrates the idea:
Code:
delete from #OPIB a inner join #OPIB b
on a.VisitID = b.VisitID
and a.EffectiveDate = b.EffectiveDate
and a.UndoDateTime is not null
and a.UndoneSeqID = b.EventSeqID
What would be the best way to delete these pairs? TIA.