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
How many categories of functions based their return modes?
Does union all remove duplicates?
Do you know the cursor types?
How column data types are determined in a view?
What is an active database?
How to get a list of columns in a view using "sys.columns" in ms sql server?
your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files? : Sql server administration
What is view in sql?
What are the different types of collation sensitivity?
How sql server executes a statement with nested subqueries?
Difference between drill down and drill through report.
SQL Server Architecture ?
Explain about SQL server 2005?
What is a recursive stored procedure in sql server?
What stored by the master?