Answered Questions

  • How to find out duplicate records in sql server?

    Star Read Best Answer

    Editorial / Best Answer

    Answered by: Hanif

    • Apr 12th, 2006


    we have to use the group by with having command to get the duplicate values. this query shall show the result of only the users have duplicate values in the employee table.

    Syntex:
    Select columnName From Table_name
    Group By columnName
    Having count (*) > 1

    Example:
    SELECT  UserID FROM employee
    GROUP BY userid
    HAVING count( * ) > 1

    nandu

    • Apr 26th, 2012

    SELECT YourColumn, COUNT(*) TotalCount
    FROM YourTable
    GROUP BY YourColumn
    HAVING COUNT(*) > 1
    ORDER BY COUNT(*) DESC

    Ramakant Sahoo

    • Dec 24th, 2011

    Code
    1. SELECT EMAIL, COUNT(*)  "REPETED EMAIL" FROM EMP GROUP BY EMAIL;