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
What is NOT NULL Constraint in sql server 2012?
Explain a checkpoint?
How do triggers work?
What is role playing dimension with two examples? : sql server analysis services, ssas
What is the use of stored procedure?
How to create a view using data from another view?
What are “phantom rows”?
How to rebuild master databse?
What is the new security features added in sql server 2014? : sql server security
What is the difference between sdf and mdf?
Explain primary key, foreign key and unique key?
Which tcp/ip port does the sql server run on? How can it be changed?
Explain about temporary stored procedure?
Explain about SQLOS?
How can I know what locks are running on which resource?