Finding Duplicates with SQL
Here’s a handy query for finding duplicates in a table. Suppose you want to find all names in a table that exist more than once:
SELECT name, COUNT(name) AS namecount FROM users GROUP BY name HAVING ( namecount > 1 )
You could also use this technique to find rows that occur exactly once:
SELECT name FROM users GROUP BY name HAVING ( COUNT(name) = 1 )
Also see How to remove duplicate rows from a table – Microsoft Knowledge base article.
- Renaming a Column in a Temporary Table in SQL Server
- How to AutoLogon in Windows 7 on startup
- How to check if the table has records or not
- How To Enable Hibernate Option In Windows 7
- Next Visual Studio going multi-screen?
- SCOPE : Optimize storing of search logs
- Viewing Shared Folders Info
- Command Line Utilities
- Recycle the ‘Recyle Bin’
- Silence the ‘Desktop Cleanup’