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 a database and a data warehouse?
Name the different type of indexes in sql?
What is cursors?
What do you know about normalization and de- normalization?
What are sql dirty pages?
Data table as parameter in sql server?
Do you know what are acid properties of transaction?
What is self contained scalar sub query?
What’s the distinction between dropping a info and taking a info offline?
What is the purpose of a table?
What is the difference between a check constraint and a rule?
What is a trace frag? Where do we use it?
How to connect sql server management studio express to sql server 2005 express?
What do you mean by sql server 2005 express management tools?
Explain what are page splits? : SQL Server Architecture