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
How do indexes help, types?
What is the difference between Clustered and Non-Clustered Index?
What do you understand by integration services in sql server?
What is normalization according to you and explain its different levels?
How do you create a data source?
How to rename an existing table with the "sp_rename" stored procedure in ms sql server?
What is the difference between char, varchar and nvarchar?
How to use “drop” keyword in sql server and give an example?
What is etl - extraction, transformation, and loading?
What is purpose of normalization?
Where are sql server user names and passwords stored in sql server?
Is null vs coalesce?
What is the security principal at the server level that represents your session?
What do you understand by triggers and mention the different types of it?
How can we improve performance by using SQL Server profiler?