if 3 duplicate records in table,i want to delete 2 alternating
duplicate records by keeping 1 duplicate and 1 original as it
is,how?
Answer Posted / sivam
sno sname salary
1 aaa 1000
1 aaa 1000
2 bbb 2000
2 bbb 2000
2 bbb 2000
1 aaa 1000
;with aa as
(
select sname,salary,ROW_NUMBER()over(partition by sno,sname,salary order by sno,sname,salary) as Nos from #testtable
)
delete from aa where Nos%2<>0
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why are views required in the sql server or in any other database?
Do you know how to store and query spatial data?
Define self join in sql server joins?
what is the difference between Tabular and Matrix report?
Explain log shipping and mention its advantages.
What are ddl (data definition language) statements for tables in ms sql server?
What is the contrast between sql and pl/sql?
How to loop through the result set with @@fetch_status?
What is difference between materialized view and view?
Which trace flags are enabled in sql server?
What are the results of running this script?
What is sql server database?
Other than truncate statement, which other command can by-pass the trigger on the tables?
How do I find information about the install locations for the various instances running on a computer?
What are trace flags?