delete duplicate orders

From: ashleyT (anonymous_at_discussions.microsoft.com)
Date: 04/12/04

  • Next message: Vishal Parkar: "Re: delete duplicate orders"
    Date: Mon, 12 Apr 2004 07:06:04 -0700
    
    

    I have an order with multiple line items. When the order comes in and put into a table I would like to check that they haven't submitted it twice. Right now I have a stored procedure that can find duplicate lines, but I really need if the whole order has been duplicated then delete it.

    So in my store procedure I use:

    SELECT COUNT(*) AS Amount,ItemNumber,Store,DeliveryDate,submission,Quantity
    FROM tblItemOrder
    GROUP BY ItemNumber,Store,DeliveryDate,submission,Quantity
    HAVING COUNT(*) > 1

    So this finds duplicate rows. But I need to find if the all rows are duplicated go ahead and delete.

    The table structure is fields Amount,ItemNumber,Store,DeliveryDate,submission,Quantity with no primary key (working table to get the data into shape).

    Even if I could find if there are the same amount of rows that have duplicates COUNT(*) > 1, then go ahead and delete the duplicates that would work fine.


  • Next message: Vishal Parkar: "Re: delete duplicate orders"

    Relevant Pages