I have a table EMP in which the values will be like this

EmpId Ename Sal DeptId
11 Ram 10000 10
11 Ram 10000 10
22 Raj 20000 20
22 Raj 20000 20
33 Anil 15000 30
33 Anil 15000 30

I want to delete only duplicate Rows. After Delete I want
the output like this

EmpId Ename Sal DeptId
11 Ram 10000 10
22 Raj 20000 20
33 Anil 15000 30



Answer Posted / guest

WITH T1 AS (
SELECT ROW_NUMBER () OVER ( PARTITION BY EmpId ORDER BY
EmpId) AS RNUM,EmpId FROM EMP)
delete
FROM T1 WHERE RNUM > 1

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how can u get last observation in an unknown dataset ?

2011


Explain how many types of relationship?

585


Explain a checkpoint?

544


Is truncate autocommit?

570


Does an index slow down updates on indexed columns?

587






Tell me time data type, datetime2, datetimeoffset data type in sql server 2008?

581


What are the difference between data mart and data warehouse? : sql server analysis services, ssas

512


Mention the command used to rename the database.

538


Can you explain various data region available in ssrs with their use?

557


What is the synonym of join?

535


Mention the uses of stored procedures.

581


Please differentiate between a local and a global temporary table?

579


Explain aggregate functions?

569


What is snapshot replication?

606


How to add the custom code in Report?

99