Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How many databases instances are there in sql server 2000?

1098


Is it true that rules do not apply to data already existing in a database at the time the rule is created?

1042


What is ssrs?

129


What is mssql?

985


What is a with(nolock)?

984


Explain aggregate functions?

1081


What factors you will consider calculating the storage requirement for that view?

949


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

1041


Write a program using SQL queries to find a unique entry in a table.

992


What objects does the fn_my_permissions function reports on? : sql server security

1034


Is sql server implemented as a service or an application? : Sql server database administration

961


What is a dbms wizard?

1020


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?

967


Tell me what are cursors and when they are useful?

954


How much memory that we are using in Logshipping Concept?

1792