Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do I edit a stored procedure in sql server?

881


What is attribute? : sql server analysis services, ssas

978


What is shared lock?

834


What is indexing and its types?

962


How to disable triggers using "disable trigger"?

1000


How to replace given values with null using nullif()?

924


Write a query to include a constraint, to check whether the employee salary is greater than 5000?

1548


What is collation sensitivity?

985


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?

2530


What is the purpose of optimization?

950


When is update_statistics command used?

996


What is the difference between mysql and sql server?

940


‘Order by’ is not allowed in a view how can you sort information from a view?

1019


What is use of except clause? How does it differ from not in clause?

962


what are constraints? Explain different types of constraints? : Sql server database administration

918