Dear All
I have a table that has many duplcates that I need to remove. I want to keep one of the duplicates and remove all others.
The table contains many columns that need to be comapred to esnure that exact diuplcates are removed.
I have run the following query:
SELECT OppPartTemp.OppProduct_ID, OppPartTemp.Opportunity_ID, OppPartTemp.StockPart_ID, OppPartTemp.SupplierPer_ID, OppPartTemp.SupplierGroup_ID, OppPartTemp.SupplierOrg_ID, OppPartTemp.Manufacturer_ID, OppPartTemp.AddDate, OppPartTemp.AddUser, OppPartTemp.ChangeDate, OppPartTemp.ChangeUser, OppPartTemp.PartNum, OppPartTemp.CustomerPartNum, OppPartTemp.BuyCurrencyCode, OppPartTemp.BuyPrice, OppPartTemp.Margin, OppPartTemp.Qty, OppPartTemp.QtyNeeded, OppPartTemp.SellCurrencyCode, OppPartTemp.ABPPrice, OppPartTemp.SellPrice, OppPartTemp.IsChosen, OppPartTemp.IsApplyDuty, OppPartTemp.IsFreight, OppPartTemp.IsCreditCard, OppPartTemp.Delivery, OppPartTemp.DeliveryUnits, OppPartTemp.DeliveryDays, OppPartTemp.SupplierNotes, OppPartTemp.RSChangeDate, OppPartTemp.RSArriveDate, OppPartTemp.RSSiteID
FROM OppPartTemp
GROUP BY OppPartTemp.OppProduct_ID, OppPartTemp.Opportunity_ID, OppPartTemp.StockPart_ID, OppPartTemp.SupplierPer_ID, OppPartTemp.SupplierGroup_ID, OppPartTemp.SupplierOrg_ID, OppPartTemp.Manufacturer_ID, OppPartTemp.AddDate, OppPartTemp.AddUser, OppPartTemp.ChangeDate, OppPartTemp.ChangeUser, OppPartTemp.PartNum, OppPartTemp.CustomerPartNum, OppPartTemp.BuyCurrencyCode, OppPartTemp.BuyPrice, OppPartTemp.Margin, OppPartTemp.Qty, OppPartTemp.QtyNeeded, OppPartTemp.SellCurrencyCode, OppPartTemp.ABPPrice, OppPartTemp.SellPrice, OppPartTemp.IsChosen, OppPartTemp.IsApplyDuty, OppPartTemp.IsFreight, OppPartTemp.IsCreditCard, OppPartTemp.Delivery, OppPartTemp.DeliveryUnits, OppPartTemp.DeliveryDays, OppPartTemp.SupplierNotes, OppPartTemp.RSChangeDate, OppPartTemp.RSArriveDate, OppPartTemp.RSSiteID
HAVING (((Count(OppPartTemp.StockPart_ID))>1));
As you can see there are many columns and this produces about 40465 duplicated records.
This happened because an import routine was run twice in error.
I have seen many solutions but they only seem to be able to handle one comparison colum.
If anybody could help, that would be great.
I have a table that has many duplcates that I need to remove. I want to keep one of the duplicates and remove all others.
The table contains many columns that need to be comapred to esnure that exact diuplcates are removed.
I have run the following query:
SELECT OppPartTemp.OppProduct_ID, OppPartTemp.Opportunity_ID, OppPartTemp.StockPart_ID, OppPartTemp.SupplierPer_ID, OppPartTemp.SupplierGroup_ID, OppPartTemp.SupplierOrg_ID, OppPartTemp.Manufacturer_ID, OppPartTemp.AddDate, OppPartTemp.AddUser, OppPartTemp.ChangeDate, OppPartTemp.ChangeUser, OppPartTemp.PartNum, OppPartTemp.CustomerPartNum, OppPartTemp.BuyCurrencyCode, OppPartTemp.BuyPrice, OppPartTemp.Margin, OppPartTemp.Qty, OppPartTemp.QtyNeeded, OppPartTemp.SellCurrencyCode, OppPartTemp.ABPPrice, OppPartTemp.SellPrice, OppPartTemp.IsChosen, OppPartTemp.IsApplyDuty, OppPartTemp.IsFreight, OppPartTemp.IsCreditCard, OppPartTemp.Delivery, OppPartTemp.DeliveryUnits, OppPartTemp.DeliveryDays, OppPartTemp.SupplierNotes, OppPartTemp.RSChangeDate, OppPartTemp.RSArriveDate, OppPartTemp.RSSiteID
FROM OppPartTemp
GROUP BY OppPartTemp.OppProduct_ID, OppPartTemp.Opportunity_ID, OppPartTemp.StockPart_ID, OppPartTemp.SupplierPer_ID, OppPartTemp.SupplierGroup_ID, OppPartTemp.SupplierOrg_ID, OppPartTemp.Manufacturer_ID, OppPartTemp.AddDate, OppPartTemp.AddUser, OppPartTemp.ChangeDate, OppPartTemp.ChangeUser, OppPartTemp.PartNum, OppPartTemp.CustomerPartNum, OppPartTemp.BuyCurrencyCode, OppPartTemp.BuyPrice, OppPartTemp.Margin, OppPartTemp.Qty, OppPartTemp.QtyNeeded, OppPartTemp.SellCurrencyCode, OppPartTemp.ABPPrice, OppPartTemp.SellPrice, OppPartTemp.IsChosen, OppPartTemp.IsApplyDuty, OppPartTemp.IsFreight, OppPartTemp.IsCreditCard, OppPartTemp.Delivery, OppPartTemp.DeliveryUnits, OppPartTemp.DeliveryDays, OppPartTemp.SupplierNotes, OppPartTemp.RSChangeDate, OppPartTemp.RSArriveDate, OppPartTemp.RSSiteID
HAVING (((Count(OppPartTemp.StockPart_ID))>1));
As you can see there are many columns and this produces about 40465 duplicated records.
This happened because an import routine was run twice in error.
I have seen many solutions but they only seem to be able to handle one comparison colum.
If anybody could help, that would be great.