Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Duplicate rows in SQL

Author  Topic 

Julie19
Starting Member

32 Posts

Posted - 2012-06-26 : 13:26:45
How to delete duplicate rows in SQL
I have a table where the data is imported daily with different dates
and I have ID's that have more than one row with the same data


Please help

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-06-26 : 13:31:20
Search "deleting duplicates" and you'll find many articles on this topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-06-26 : 14:02:21
quote:
Originally posted by Julie19

How to delete duplicate rows in SQL
I have a table where the data is imported daily with different dates
and I have ID's that have more than one row with the same data


Please help



can you copy and paste a sample of data please to help up help you!



--------------------------
Get rich or die trying
--------------------------
Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-06-26 : 23:46:34

sample script to delete duplicate records.


delete d from
(
select *, row_no = row_number() over (partition by esn, shipdate, model_code, supplierid order by esn)
from YourTable where ESN='270113179912138090'
) d
where d.row_no <> 1


Go to Top of Page

Julie19
Starting Member

32 Posts

Posted - 2012-06-29 : 11:41:50
test
Go to Top of Page
   

- Advertisement -