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 do I open port 1433?

880


Can the query output be sorted by multiple columns in ms sql server?

935


How to list all login names on the ms sql server?

1078


What are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture

949


Is it true, that there is no difference between a rule and a check constraint?

972


How to backup SQL Server Reporting Services ?

137


What does it mean to invest in the index?

905


do you know what is a deadlock and what is a live lock? How will you go about resolving deadlocks? : Sql server database administration

920


Is it possible to create trigger on views?

934


How to replace given values with null using nullif()?

924


What happens if date-only values are provided as date and time literals?

975


What structure can you implement for the database to speed up table reads?

1154


What is logshipping and its purpose?

944


How to convert a numeric expression from one data type to another?

933


How can we check the sql server version?

981