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


Please Help Members By Posting Answers For Below Questions

What are the source of constraints?

665


Why truncate is ddl?

811


What is the main purpose of having conversation group?

660


What stored by the master? : sql server database administration

747


Define a cross join?

758






SQL Server Architecture ?

2124


How to handle error or exception in sql?

701


How many databases Microsoft SQL server provides?

775


Define tool Manage Statistics in SQL Server 2000 query ?

729


What is an index. What are the types?

750


Explain what you mean by 3 tier architecture.

800


What is amo? : sql server analysis services, ssas

836


What happens if you are trying to access a schema not owned by you?

716


hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.

2673


Tell me about builtinadministrator?

724