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 are the differences between char and nchar in ms sql server?

1008


What is 1nf 2nf?

962


What can be used instead of trigger?

1097


Explain the properties of sub-query in sql server?

954


How to count rows with the count(*) function in ms sql server?

951


How do you trace the traffic hitting a sql server?

1069


Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?

112


What programming language would you use to create embedded functions in ssrs?

172


What is ms sql server reporting services?

991


What is Lock table in SQL?

1410


Is foreign key unique?

957


Explain different types of index?

985


What are basics of policy management?

1049


Equi join and non equi join is possible with sql server?

937


What is the difference between getdate and sysdatetime?

940