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 retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?

Answer Posted / samba shiva reddy . m

How to retrieve the duplicate rows in table :

select * from emp group by empid,empname having count(empname)>1

How to delete the duplicate rows in table :
1.inserting distinct rows in temp table variable
2. deleting emp table
3.Again inserting into emp table from temp table variable


declare @temp table
(empid int,empname varchar(50))
insert into @temp
select * from emp group by empid,empname having count(empname)>0
delete from emp
insert into emp
select * from @temp
select * from emp

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a ddl statement?

913


Explain the etl (extraction, transformation, and loading)?

995


In how many ways you can invoke ssrs reports?

139


How to create a new schema in a database?

1151


What is meant by indexing files?

1042


What is a cube? : sql server analysis services, ssas

999


What is difference between drop truncate and delete?

1094


What happens when converting big values to numeric data types?

1135


How do I clean up sql server transaction log?

1066


How to drop existing views from a database in ms sql server?

1103


Is it possible to create trigger on views?

982


How to test values returned by a subquery with the in operator?

1197


Why use triggers?

1014


How to change server name in sql server?

1184


How to list all dsn entries on your local machine using odbc_data_source()?

1039