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
what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?
Is it possible to update the views? If yes, how, if not, why?
How to loop through returning rows?
What is dirty read?
Explain subquery and state its properties?
What is the difference between createstatement and preparedstatement?
What is coalesce and check constraint in sql server?
What are the differences between “row_number()”, “rank()” and “dense_rank()”?
How to check status of stored procedure in sql server?
what is new philosophy for database devises for sql server 7.0? : Sql server database administration
What are parameterized reports? What are cascading parameters in ssrs reports?
What is the sql profiler?
What types of replication are supported in sql server?
Does sql server use java?
What is indexing in sql server with example?