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 are the benefits and tasks of object explorer? : sql server management studio
What are the limitations in ssrs on sql server express edition?
what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration
What is normalization and what are the advantages of it?
What are page splits? : SQL Server Architecture
What are the instances when triggers are appropriate?
Tell me about pre-defined functions of sql?
What are the types of indexing?
What is sqlservr.exe - process - sql server (sqlex?press)?
How to attach adventureworkslt physical files to the server?
What is filestream?
Explain the database you used in your final year project?
What is oltp (online transaction processing)?
how to overcome kernel isssues
What do you mean by an execution plan? Why is it used?