how to delete duplicate rows from table in sql server
Answer Posted / manjeet kumar
delete from table_name where column_name='value' and rowid
not in (select max(rowid) from table_name where
column_name='value');
e.g. create table duplicate (name varchar(15), rollno number
(10));
insert into duplicate (name,rollno) values ('mkumar',2);
insert into duplicate (name,rollno) values ('mkumar',2);
delete from duplicate where name='mkumar' and rowid not in
(select max(rowid) from duplicate where name='mkumar');
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
How to replace given values with null using nullif()?
why would you call update statistics? : Sql server database administration
Explain about unique identifier data type in sql server?
Explain transaction server isolation?
List the ways in which dynamic sql can be executed?
If I delete a template from the list in sql studio, will it be deleted from the hard disk? : sql server management studio
How to use “drop” keyword in sql server and give an example?
Do you know what is difference between stored procedure and user defined function?
What do you understand by a view? What does the with check option clause for a view do?
Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?
Describe the left outer join & right outer join. : sql server database administration
how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration
What is 3nf normalization form?
How many types of triggers in sql server?
What does indexation mean?