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 to Check if table exists in sql server?
What are the essential components of sql server service broker?
Why olap is used?
What is implicit mode in sql server?
Explain the truncate command?
Does hive support indexing?
What is the purpose of data source?
what is the system function to get the current user's user id? : Sql server database administration
How to write the storeprocedure with in the store procedure? and how can we write the store procedure with in a trigger vice versa? plz post me the exact answer?
What is the difference between cube operator and rollup operator? : SQL Server Architecture
Explain can SSRS reports Cache results?
Explain about Views?
What is the most common trace flags used with sql server?
How to set database to be read_only in ms sql server?
What is triggers in ms sql server?