Is it possible to delete duplicate rows in a table without
using a temporary table ?
Answer Posted / balaji
yes its very much possible.
create table #student
(name varchar(10),age integer)
insert into #student values ('A',12)
go 2
insert into #student values ('B',13)
go 3
insert into #student values ('C',15)
go 4
insert into #student values ('D',14)
go 5
SET ROWCOUNT 1
DELETE #student FROM #student A WHERE (SELECT COUNT(*) FROM
#student B WHERE A.NAME = B.NAME AND A.AGE = B.AGE) > 1
WHILE @@ROWCOUNT > 0
DELETE #student FROM #student A WHERE (SELECT COUNT(*) FROM
#student B WHERE A.NAME = B.NAME AND A.AGE = B.AGE) > 1
SET ROWCOUNT 0
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Difference between report and query parameter. Why do we need different type of parameter?
What is a schema in ms sql server 2005?
Where is localdb stored?
What new data source types were added in ssrs 2014?
Do you know what are the restrictions that views have to follow?
Explain how to use linked server?
How to create a testing table with test data in ms sql server?
What is difference in performance between insert top (n) into table and using top with insert?
what is the system function to get the current user's user id? : Sql server database administration
Explain having clause?
How to define and use table alias names in ms sql server?
What is inner join in sql server joins?
What is the difference between set and select?
What is the difference between primary key and unique constraints?
Does union all remove duplicates?