So what do I do once the data is in my table Do I write and execute a script that will check the table and perform the delete if required I think that this is probably correct. I do have a very old script that I found in a Google search, but it seems so long and convoluted.
I'm hoping for a very simple solution, or script that will simply compare the names and then delete any extra instances greater than one i.e. leave at least one instance of every name.
I am new to databases, but I find it hard to believe that dealing with duplicates would be a difficult issue, surely this is an area that every DB has to contend with eventually. How would you check and delete duplicates in a table Remembering that I want to delete the entire row, not just the name in the name column. I would really appreciate any tips, urls, or sample code in this matter.
Tia
<woof>Tailwag</woof>

Delete Duplicates in SQL2005
dsani
To the moderators of this forum, please move this thread to a more appropriate forum if you think I moved this thread to a wrong forum.
Regards,
-chris
Darrell Davis
Thanks Chris, I must have been on something when I posted the question in the wrong section, that is very poor form :-(
Perhaps now someone will answer me :-)
Cheers
Jason Matkowsky
Then you can do something like this:
delete from myTable
where primarykeycolumn < (
select max(primarykeycolumn) from myTable as Tmatch
where Tmatch.namecolumn = myTable.namecolumn
)
This should be done in a staging table, and your destination table should have UNIQUE and NOT NULL constraints on the name column so you never have duplicate names in that table, if that's what you want. ("Sorry, Mrs. Patel. We already have a customer with your name, so you'll have to buy your car somewhere else.")
Steve Kass
Drew University