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
Can we call future method from trigger?
How to convert a numeric expression from one data type to another?
List few advantages of stored procedure.
Can we call stored procedure in trigger?
When we should use and scope of @@identity?
How to drop an existing user defined function in ms sql server?
What are the differences between stored procedure and view in sql server?
How to execute stored procedure and set temp table in sql server?
What is the use of toad or sqldbx.?
What is a deadlock and what is a live lock?
Explain how would you store your query in an SSRS report or a Database server?
what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration
How will you monitor replication latency in transactional replication? : sql server replication
What are cascading parameters in ssrs reports?
Write a sql query to delete duplicate records from a table called table1