• SELECT * into #tempDocFragToDelete FROM

    DocumentFragmentRelationShipHistory WHERE DocumentFragmentMasterId =391

    AND DocumentFragmentVersionID=1.0

    DELETE a from DocumentFragmentRelationShipHistory a join #tempDocFragToDelete b

    on a.DocumentFragmentMasterId = b.DocumentFragmentMasterId

    where a.DocumentFragmentVersionID > b.DocumentFragmentVersionID

    This one is a real running example, try this.