Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 333679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:59:01+00:00 2026-05-12T09:59:01+00:00

I tried to delete duplicate records in my DB. The only difference is the

  • 0

I tried to delete duplicate records in my DB. The only difference is the PrimaryKey which is a uniqueidentifier. I have about 1500 entries that have been duped so in all I’m looking at around 3000 entries. So I sectioned off about 60 entries (based on the receivedOn date) and executed my code to pare them down to 30 and OH CRAP the 30 disappeared! Here is the code I tried:

DELETE dupes
FROM [emailTable] dupes, [emailTable] fullTable
WHERE (dupes.ReceivedOn > '2009-08-18 23:59:59.999' AND dupes.ReceivedOn < '2009-08-20 00:00:00.000')
      AND (dupes.emlPath = fullTable.emlPath)
      AND NOT (dupes.GUID = fullTable.GUID)

My goal is to delete the duplicate. I dont care which one… but I need ONE of the two entries to stay on the server… Can anybody shed some light on what I did wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:59:02+00:00Added an answer on May 12, 2026 at 9:59 am

    You can do this without a second table. Something like this:

    SELECT * FROM emailTable
    WHERE EXISTS (
        SELECT * FROM emailTable AS t2
        WHERE t2.emlPath = emailTable.emlPath AND
        t2.GUID > emailTable.GUID)
    

    That will show you which records are about to get deleted. If that’s okay, change it to:

    DELETE FROM emailTable
    WHERE EXISTS (
        SELECT * FROM emailTable AS t2
        WHERE t2.emlPath = emailTable.emlPath AND
        t2.GUID > emailTable.GUID)
    

    The t2.GUID > emailTable.GUID will make sure that one record with that emlPath will remain in the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with finding and deleting duplicate records, I have a table
I have an Access 2003 table with ~4000 records which was made from 17
SQL to find duplicate entries (within a group) I have a small problem and
I've got an issue involving a website that I have been using VS 2008
I need to delete about 2 million rows from my PG database. I have
I have tried to delete an item from a string divided with commas: var
MySQL/ASP - Delete Duplicate Rows I have a table with 100,000 rows called 'photoSearch'.
I have a lot of warnings in my Xcode project about old files that
Has anyone tried out working with the Delete and update command of SPDataSource used
How do I securely delete files in java? I tried the code at javafaq.nu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.