Click here to Skip to main content
13,769,953 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


27 bookmarked
Posted 26 Oct 2014
Licenced CPOL

Delete duplicate rows in SQL Server

, 26 Oct 2014
Rate this:
Please Sign up or sign in to vote.


Some time some duplicate data may inserted in the SQL table. But its harmful for you and your application too. So how to remove the duplicate rows in your table.


Take a look in the following table content. Its having duplicate rows.

Id       Name           Department

1        Arka               .NET

2        Ashok            .NET

3        Anubhav        php

4        Arka               .NET

5        Sucheta          Graphics

Row 1 and 4 are duplicate. So we have to remove one row and keep one in the table.

Now question is how to do?

Using the code

To solve this problem take a look at the following code. This will solve this problem.

WITH tblTemp as
   As RowNumber,* FROM <table_name>
DELETE FROM tblTemp where RowNumber >1

After run these code show the table data, it will all unique rows present.


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


About the Author

Arkadeep De
Software Developer Cognizant
India India
I am a Software developer having an experience of 4 years in application development. To get me you can mail me at or you can visit my blog at ASP With Arka

You may also be interested in...

Comments and Discussions

Praiseit's cool Pin
Ronald Luna Ramos30-Jan-18 3:35
memberRonald Luna Ramos30-Jan-18 3:35 
PraiseThank you, Thank you Pin
Ntingab5-May-16 5:04
memberNtingab5-May-16 5:04 
QuestionTHANKS Pin
Member 871442124-Jul-15 11:24
memberMember 871442124-Jul-15 11:24 
QuestionAnother simple solution Pin
govardhan4u29-Oct-14 7:18
membergovardhan4u29-Oct-14 7:18 
AnswerRe: Another simple solution Pin
Arkadeep De2-Nov-14 7:48
professionalArkadeep De2-Nov-14 7:48 
AnswerRe: Another simple solution Pin
aarif moh shaikh8-Mar-15 21:25
professionalaarif moh shaikh8-Mar-15 21:25 
QuestionDistinct keyword Pin
Lorenzo A.28-Oct-14 23:17
memberLorenzo A.28-Oct-14 23:17 
AnswerRe: Distinct keyword Pin
Arkadeep De29-Oct-14 0:28
professionalArkadeep De29-Oct-14 0:28 
GeneralUNIQUE constraint? Pin
Gheorghe Musca28-Oct-14 22:15
memberGheorghe Musca28-Oct-14 22:15 
GeneralRe: UNIQUE constraint? Pin
Arkadeep De29-Oct-14 0:32
professionalArkadeep De29-Oct-14 0:32 
GeneralMy vote of 5 Pin
dmjm-h28-Oct-14 12:20
memberdmjm-h28-Oct-14 12:20 
GeneralRe: My vote of 5 Pin
Arkadeep De29-Oct-14 0:31
professionalArkadeep De29-Oct-14 0:31 
GeneralMy vote of 5 Pin
E. Scott McFadden28-Oct-14 9:33
professionalE. Scott McFadden28-Oct-14 9:33 
GeneralRe: My vote of 5 Pin
Arkadeep De29-Oct-14 0:30
professionalArkadeep De29-Oct-14 0:30 
QuestionVery nice. Pin
Member 1017996028-Oct-14 8:42
memberMember 1017996028-Oct-14 8:42 
AnswerRe: Very nice. Pin
Arkadeep De29-Oct-14 0:30
professionalArkadeep De29-Oct-14 0:30 
QuestionMy Vote of 5 Pin
Rajesh waran28-Oct-14 0:50
professionalRajesh waran28-Oct-14 0:50 
AnswerRe: My Vote of 5 Pin
Arkadeep De28-Oct-14 1:55
professionalArkadeep De28-Oct-14 1:55 
GeneralRe: My Vote of 5 Pin
Rajesh waran28-Oct-14 2:15
professionalRajesh waran28-Oct-14 2:15 
GeneralMy vote of 5 Pin
Humayun Kabir Mamun27-Oct-14 2:57
memberHumayun Kabir Mamun27-Oct-14 2:57 
GeneralRe: My vote of 5 Pin
Arkadeep De27-Oct-14 3:20
professionalArkadeep De27-Oct-14 3:20 

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 | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.181119.1 | Last Updated 27 Oct 2014
Article Copyright 2014 by Arkadeep De
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid