How to retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?

Answer Posted / lince thomas

it is very simple,,below
------------------------
select * from(
select row_number() over(partition by empname order by
empname)as rno,empname,salary from Emp1Pay)T
where T.rno>1


delete from Emp1Pay where empid=
(select empid from(select row_number() over(partition by
empname order by empname)as rno,empid
from Emp1Pay )T where T.rno>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 is a sql join?

576


What is database dimension? : sql server analysis services, ssas

628


How do use Having,Group by,Group function in SQL?

1362


What are security principals used in sql server 2005?

519


What is an example of a foreign key?

516






How to use values from other tables in update statements in ms sql server?

563


Does table partitioning improve performance?

538


What is difference between commit and rollback when used in transactions?

504


Explain the steps to use transact-sql cursor?

530


what is a default tcp/ip socket assigned for sql server? : Sql server database administration

535


what are acid properties? : Sql server database administration

497


Is it possible in sql table to have more than one foreign key?

618


To automatically record the time on which the data was modified in a table, which data type should you choose for the column?

545


Which operator do you use to return all of the rows from one query except rows are returned in a second query?

577


sql database suspect We have a sql database that is showing as suspect. How can we recover?

1408