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
Explain the purpose of indexes?
what are the different types of replication you can set up in sql server? : Sql server database administration
Explain the database you used in your final year project?
How can windows applications connect to sql servers via odbc?
What is the New in SQL server 2008?
Can you tell me some of the common replication dmv's and their use? : sql server replication
What are different types of roles provided by ssrs?
How to truncate the log in sql server 2012? : sql server database administration
Why is sql server log file full?
What does the on delete cascade option do?
explain different levels of normalization? : Sql server database administration
What do you mean by normalisation?
Where to find ntwdblib.dll version 2000.80.194.0?
Where are full-text indexes stored?
What is the use of RDBMS?