Archive

Posts Tagged ‘mutiple rows’

How to find multiple/duplicate rows with the same value

June 27th, 2008 Rahmansaher No comments

Just a short SQL script which will allow you to find the mutiple rows with the same values in the same table. I am not going to explain what the query does since its a very straight forward query

SQL:
  1. SELECT [column_name]
  2. FROM [tablename]
  3. GROUP BY [column_name]
  4. HAVING count(*)> 1
  5. --  OR
  6.  
  7. SELECT * FROM [TableName] WHERE [ColumnName] IN (
  8. SELECT [ColumnName] FROM (
  9. SELECT count([ColumnName]) AS N, [ColumnName] FROM [TableName]
  10. -- Where Clause If needed
  11. GROUP BY [ColumnName]
  12. )a
  13. WHERE N> 1
  14. )

There is a similar article which describes more techniques to follow for managing duplicate rows from a table .

http://support.microsoft.com/kb/139444

Sphere: Related Content