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
What are the differences between char and nchar in ms sql server?
What is 1nf 2nf?
What can be used instead of trigger?
Explain the properties of sub-query in sql server?
How to count rows with the count(*) function in ms sql server?
How do you trace the traffic hitting a sql server?
Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?
What programming language would you use to create embedded functions in ssrs?
What is ms sql server reporting services?
What is Lock table in SQL?
Is foreign key unique?
Explain different types of index?
What are basics of policy management?
Equi join and non equi join is possible with sql server?
What is the difference between getdate and sysdatetime?