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?