delete extra records

  • Hi again,

    I found how to eliminate duplicate contacttypes for the same fkProjectID as below, keeping the newest by DateCreated. So now I think I only have to delete the 'firstcontact' if I have a 'secondcontact' for the same fkProjectID. Please advise if I am going about this the right way. I try to break the problem down into pieces.

    DELETE FROM T1

    FROM #header T1, #header T2

    WHERE T1.fkProjectID = T2.fkProjectID

    AND T1.ContactType = T2.ContactType

    AND T1.DateCreated < T2.DateCreated

    Warm regards,

  • Hi again,

    I got it done! Did the same delete a second time only with firstcontact < secondcontact.

    DELETE FROM T1

    FROM #header T1, #header T2

    WHERE T1.fkProjectID = T2.fkProjectID

    AND T1.ContactType < T2.ContactType

    Warm regards,

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply