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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Eliminate Duplicate Enty

Author  Topic 

jess1984
Starting Member

14 Posts

Posted - 2010-10-12 : 10:04:38
Hai,
In my sql table, some row with Airline_Id,Aircraft_Series_Id,Charges_Id replicated.
i need to delete all duplicate data


Plz help.....
Thanks in advance
Jess

jess1984

theboyholty
Posting Yak Master

226 Posts

Posted - 2010-10-12 : 11:38:59
You can always use SELECT DISTINCT. This will remove any duplicates but you musn't let it be a get-out clause for lazy coding. There's usually a reason for duplicate rows if you're not expecting them and its better to write this out of the SQL code before relying on SELECT DISTINCT.

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-12 : 11:58:02
Test it:

delete dt
from
(
select
row_number() over (partition by Airline_Id,Aircraft_Series_Id,Charges_Id
order by Airline_Id,Aircraft_Series_Id,Charges_Id) as rownum,
*
from your_table)dt
where rownum > 1



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -