Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hai, In my sql table, some row with Airline_Id,Aircraft_Series_Id,Charges_Id replicated.i need to delete all duplicate dataPlz help.....Thanks in advanceJessjess1984
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
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2010-10-12 : 11:58:02
Test it:
delete dtfrom(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)dtwhere rownum > 1
No, you're never too old to Yak'n'Roll if you're too young to die.