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 databases instances are there in sql server 2000?
Is it true that rules do not apply to data already existing in a database at the time the rule is created?
What is ssrs?
What is mssql?
What is a with(nolock)?
Explain aggregate functions?
What factors you will consider calculating the storage requirement for that view?
It is important form e to get the information from log files of applications executed by the task scheduler? Does sql studio save these log files? : sql server management studio
Write a program using SQL queries to find a unique entry in a table.
What objects does the fn_my_permissions function reports on? : sql server security
Is sql server implemented as a service or an application? : Sql server database administration
What is a dbms wizard?
If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?
Tell me what are cursors and when they are useful?
How much memory that we are using in Logshipping Concept?