5 pts.
 SQL find duplicates SQL Server 2008
Up against a SQL question that is difficult to code.  Any help is greatly appreciated.

Software/Hardware used:
SQL Server 2008
ASKED: March 14, 2010  8:47 PM
UPDATED: March 22, 2010  12:44 PM

Answer Wiki:
If you have a table called T1, and the columns are c1, c2 and c3 then this query would show you the duplicate values. <pre> SELECT C1, C2, C3, count(*) from T1 GROUP BY C1, C2, C3 HAVING COUNT(*) <> 1</pre>
Last Wiki Answer Submitted:  March 15, 2010  4:17 am  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Remember that you can use the ‘search’ feature of the site.

This is another question you might want to take a look at:

Fastest “get duplicates” SQL

 63,535 pts.

 

Define a unique index (or however your RDBMS supports a unique constraint) on a column or set of columns and avoid “duplicates”

 5,205 pts.

 

You can find the duplicates also in this way in SQL Server 2008;

WITH DUPLO
AS
(SELECT ROW_NUMBER() OVER (PARTITION BY YOUR_COLUMN_WITH_DOUBLE_VALUE ORDER BY YOUR_COLUMN_WITH_DOUBLE_VALUE) AS DUPLOID, * FROM YOURTABLE)

SELECT * FROM DUPLO
WHERE DUPLOID <> 1
 10 pts.