Search This Blog

Saturday, April 17, 2010

SQL Find Duplicate Data

This is very interesting SQL query to find exact no of same / Duplicate data in a row of table.

To -Find duplicate value in Field

SELECT Filed1,
COUNT(Field1) AS CountField
FROM table
GROUP BY Field1
HAVING ( COUNT(Field1) > 1 )

To -Find field have no duplicate Value

SELECT Filed1,
COUNT(Field1) AS CountField
FROM table
GROUP BY Field1
HAVING ( COUNT(Field1) = 1 )

No comments:

Post a Comment