Announcement

Collapse
No announcement yet.

Delete duplicate records

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delete duplicate records

    Hi,

    I'm uploading excel files to my server to import into my db. I need to delete duplicate combo primary key values from the temp table created. So far I have:

    sc_exec_sql("select PARPRT_02, COMPRT_02, count(*)
    from table_name
    group by PARPRT_02, COMPRT_02
    having count(*) > 1
    DELETE FROM Product_Structure_[PMdate] WHERE PARPRT_02 ");

    but I am not grasping how to accomplish the finishing blow.

    Thanks,
    Damian
    HA! We're all just a little crazy.

  • #2
    Assuming you have a unique ID on each record, you could do something lime

    DELETE a
    FROM table_nameas a, table_nameas b
    WHERE
    (a.PARPRT_02 = b.PARPRT_02 OR a.PARPRT_02 IS NULL AND b.PARPRT_02 IS NULL)
    AND (a.COMPRT_02 = b.COMPRT_02 OR a.COMPRT_02 IS NULL AND b.COMPRT_02 IS NULL)
    AND a.ID < b.ID;
    Will
    www.willhogarth.com

    Comment


    • #3
      Hi William,
      it is a Primary combo key of PARPRT_02 AND COMPRT_02. I'll give this a try.

      Thanks
      HA! We're all just a little crazy.

      Comment

      Working...
      X