SQL find duplicates SQL Server 2008

5 pts.
Tags:
SQL Find
SQL Server
SQL Server 2008
Up against a SQL question that is difficult to code.  Any help is greatly appreciated.

Software/Hardware used:
SQL Server 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.

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>

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    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
    68,495 pointsBadges:
    report
  • Meandyou
    Define a unique index (or however your RDBMS supports a unique constraint) on a column or set of columns and avoid "duplicates"
    5,220 pointsBadges:
    report
  • Dugi
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following