We are having large data base and it's having vast records for example we have 10 millins of records in a data abse then we will find what are all the duplicates records based some sriteria. following is the example query.
Query:
SELECT au_lname, au_fname, city, state, RecCount=COUNT(*), PktoKeep = MAX(NewPK)
INTO #DUPLICATES
FROM dup_authors
GROUP BY au_lname, au_fname, city, state
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC, au_lname, au_fname
'INTO' is a clause it inserts the selection data in to 'DUPLICATES' temporary table.
No comments:
Post a Comment