SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Duplicate rows in SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Julie19
Starting Member

32 Posts

Posted - 06/26/2012 :  13:26:45  Show Profile  Reply with Quote
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

USA
35017 Posts

Posted - 06/26/2012 :  13:31:20  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

USA
261 Posts

Posted - 06/26/2012 :  14:02:21  Show Profile  Reply with Quote
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

315 Posts

Posted - 06/26/2012 :  23:46:34  Show Profile  Reply with Quote

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



Edited by - Villanuev on 06/26/2012 23:47:27
Go to Top of Page

Julie19
Starting Member

32 Posts

Posted - 06/29/2012 :  11:41:50  Show Profile  Reply with Quote
test
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000