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
How do you set a trace flag in sql server?
Name and describe few console utilities for ssrs?
Can we use pragma autonomous_transaction in trigger?
Why do you need a sql server?
how to restart sql server in single user mode? How to start sql server in minimal configuration mode? : Sql server database administration
what is difference between view and Dip.
How to list all login names on the ms sql server?
Explain about sql server login?
What is a livelock?
What is 2nf normalization?
How to update multiple rows with one update statement in ms sql server?
How is a full-text index updated?
Explain the steps to use transact-sql cursor?
What is the maximum number of instances in 32 bit and 64 bit sql server 2012?
How to create a login account in ms sql server to access the database engine using "create login" statements?