Recently I was trying to find duplicate records in a table. The records are considered duplicate if two columns in different records has the same value. For example if first name and last name is same in record1 and record2, they considered as duplicate.
The below query will help to find the duplicate records.
SELECT fname, lname, COUNT(*) AS DuplicateCount FROM [Users]GROUP BY fname, lname HAVING COUNT(*) > 1ORDER BY COUNT(*), fname.
(I know this is pretty simple one, but most of the time you struggle for the simplest query :) so thought of sharing it)
Disclaimer Postings are provided as is with no warranties, and confer no rights. Opinions expressed here are my own delusions; my employers at best shake their heads and sigh, at worst repudiate the content with extreme prejudice, whenever it manages to appear on their radar.