Write a query to delete duplicate records in SQL SERVER

Answer Posted / prasant ojha

create a table tbl_info
(
name varchar(250),
age int
)
Enter values

'RAM',25
'SHYAM',34
'RAM',25
'GHANSHYAM',25
'RAM',25

//SQL QUERY TO REMOVE DUPLICATE RECORDS WITHOUR ANY KEY
with info_tbl as(

SELECT *,row_number() over(partition by name order by name)
as record_no from tbl_info
)
delete from info_tbl where record_no>1

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 audit control procedures?

589


What is spid in sql server profiler?

542


When we should use and scope of @@identity?

557


Can coalesce return null?

549


Explain transaction server isolation?

553






How do triggers work?

542


What is an entity-relationship diagram (erd)?

592


What is the definition for sql server 2000?

599


what is a deadlock? : Sql server database administration

503


What should be the fill factor for indexes created on tables? : sql server database administration

630


what is denormalization and when would you go for it? : Sql server database administration

709


What is a transactions?

606


Explain in details security in SQL azure?

97


What causes index fragmentation?

584


Why olap is used?

573