Click here to Skip to main content
15,886,519 members
Articles / Database Development / SQL Server
Tip/Trick

To find duplicate rows in table

Rate me:
Please Sign up or sign in to vote.
4.91/5 (4 votes)
31 Jan 2012CPOL 46.3K   6   1
To find duplicate rows in table
SQL
--To find duplicate rows in table

select colname, count(colname) from TableName
Group by colname Having (count(colname) > 1)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
.Net Programmer

Comments and Discussions

 
GeneralIf colname allows NULL value then use count(*) instead of co... Pin
BoBsEd2-Feb-12 1:47
BoBsEd2-Feb-12 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.