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 to check what was the last restore transaction LSN in Log shipping or Mirroring? when we don't have a Monitor or witness server.
What does ss stand for sexually?
Define outer join in sql server joins?
Do you know what is blocking?
How to use union to merge outputs from two queries together in ms sql server?
What is stored in the mssqlsystemresource database? : sql server database administration
What is the current limitation of the size of SQL Azure DB?
How to change the data type of an existing column with "alter table" statements in ms sql server?
What is user-defined inline table-valued function?
What is bookmark link in ssrs?
What is indexed view?
Explain different forms of normalization?
What do you understand by triggers and mention the different types of it?
What is single-user mode?
Describe in brief authentication modes in sql server.