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

Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?

904


Can we call stored procedure in view in sql server?

867


What is create command?

937


What are the different types of sql server replication? : sql server replication

1182


What is default constraint in ms sql server?

977


What is spatial and temporal data?

940


Which are ddl commands?

992


Explain datetime2 data type in sal server 2008?

866


Explain primary key and foreign key constraints?

973


What are the different types of subquery?

1105


What is set nocount on?

902


What do you mean by 'normalization'?

1016


but what if you have to create a database with two filegroups, one on drive c and the other on drive d with log on drive e with an initial size of 600 mb and with a growth factor of 15%? : Sql server database administration

932


What is SQL Azure Data sync?

119


What are commit and rollback in sql?

1074