|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a utility that uploads to a SQL table and gives each record a unique key. The utility checks all the records for a marker to see if it has been uploaded or not. Occasionally it will not mark the record and upload two or three times or more. Since it generates a unique key on upload, how do you run a query that will find and delete all the duplicates and leave on of the original records that were duplicated?
I have about 25 fields in the SQL table, and the "id" is the SQL table key, and the invoice is the key from my original table that I upload from. So if I have invoice numbers 1, 2, 2, 3, 4, 5 you can see that I have to delete one of the records with an invoice of "2." The problem is that I have about 131,000 records and about 30,000 duplicates. How can I fix this? Thanks, Joe |
|
#2
|
||||
|
||||
|
Which field contains the duplicated data?
It would be something like this, depending on you data types. Code:
SELECT DISTINCT FieldName FROM TableName GROUP BY FieldName HAVING COUNT(*) > 1 |
|
#3
|
|||
|
|||
|
every field has a dup, except the key id for those dup records. I still need to keep 1 of the dup records, and delete the rest.
|
|
#4
|
||||
|
||||
|
try my example and just insert a field name that contains duplicate information.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > distinct column |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|