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 / 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 | 0 No |
Post New Answer View All Answers
What is SQL Azure?
What is a print index?
What is the name of the Database which IBM mainframe uses?
Explain Reporting Life Cycle?
What is a rownum?
What is the difference between a fill factor of 100 and 0?
What is sqlcmd?
What is a trigger in sql server?
Can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible?
Explain what are partitioned views and distributed partitioned views?
Can sub report data source be different from that of the parent report?
How do triggers work?
How to create function with parameter in sql server?
What does dml stand for?
what is sql server? : Sql server database administration