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
Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?
Can we call stored procedure in view in sql server?
What is create command?
What are the different types of sql server replication? : sql server replication
What is default constraint in ms sql server?
What is spatial and temporal data?
Which are ddl commands?
Explain datetime2 data type in sal server 2008?
Explain primary key and foreign key constraints?
What are the different types of subquery?
What is set nocount on?
What do you mean by 'normalization'?
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
What is SQL Azure Data sync?
What are commit and rollback in sql?