Click here to Skip to main content
13,150,178 members (55,186 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.2K views
Posted 1 Feb 2012

To find duplicate rows in table

, 1 Feb 2012
Rate this:
Please Sign up or sign in to vote.
Here is an alternative way to find duplicates in a table by making use of over clause http://msdn.microsoft.com/en-us/library/ms189461.aspx[^];with duplicates as (SELECT rowno=row_number() over (partition by colname order by colname), colname, colname from TableName)select * from...
Here is an alternative way to find duplicates in a table by making use of over clause http://msdn.microsoft.com/en-us/library/ms189461.aspx[^]

;with duplicates as (SELECT rowno=row_number() over (partition by colname order by colname), colname, colname from TableName)
select * from duplicates where rowno > 1


The above query also makes it easier to delete duplicates from your table, just replace "select * from" to "delete from" and it will become an effective delete statement.

License

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

Share

About the Author

Member 7759061
South Africa South Africa
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 5 from a long time i was looking for a... Pin
nikhi _singh2-Feb-12 18:00
membernikhi _singh2-Feb-12 18:00 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170924.2 | Last Updated 1 Feb 2012
Article Copyright 2012 by Member 7759061
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid