Rem *** Remove duplicate entries ***
SQL$ = "SELECT [Mach], [Datim], COUNT(*) - 1 From [Tunl_CustHist] GROUP BY [Mach], [Datim] HAVING COUNT(*) > 1"
rs.Open SQL$, verDB, adOpenForwardOnly, adLockReadOnly
While Not rs.EOF
If booSQLServer Then 'global variable telling me which type of database I'm dealing with
SQL$ = "DELETE FROM [Tunl_CustHist] WHERE [Mach] = " & CInt(rs![Mach]) & " AND [Datim] = '" & rs![datim] & "'"
Else
SQL$ = "DELETE * FROM [Tunl_CustHist] WHERE [Mach] = " & CInt(rs![Mach]) & " AND [Datim] = #" & rs![datim] & "#"
End If
verDB.Execute SQL$, , adExecuteNoRecords
rs.MoveNext
Wend
rs.Close
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)