How to delete duplicate records from a table?(for suppose in
a table we have 1000 Records in that we have 200 duplicate
Records , so ,how to findout that duplicate Records , how to
delete those Records and arranged into sequence order? one
more thing that there is no primary key at all)

Answer Posted / smitha

;with empctc(empid,ename,sal,deptid,ranking)
as
(Select empid,ename,sal,deptid,ranking=Dense_rank() over (
partition by empid,ename,sal,deptid order by NEWID() asc)
from emp
)
delete * from empctc where ranking>1

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the stored procedure?

642


How will you monitor replication activity and performance? What privilege do you need to use replication monitor? : sql server replication

556


you accidentally delete the msdb database what effect does this have on your existing sql databases, and how do you recover? : Sql server administration

722


Explain “@@rowcount” and “@@error” in sql server?

541


What is change data capture (cdc) feature?

594






What is the tcp/ip port on which sql server runs?

570


What is fill factor and pad index?

548


What is the purpose of floor function?

543


How to list all schemas in a database?

582


Can we create clustered index on composite key?

519


What is the optimal disk configuration for a database server and what raid configurations would you use if budget is not a constraint?

487


What types of Joins are possible with Sql Server?

553


Write the queries for commands like Create Table, Delete table, Drop Table etc.

615


How can you stop stored procedures from recompiling?

492


What is raid? : SQL Server Architecture

600