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...

how to delete duplicate rows from table

Answer Posted / divya mahendra sikarwar

Execute queries:

CREATE TABLE dbo.Test1 (
[ID] [int] ,
[FirstName] [varchar](25),
[LastName] [varchar](25)
) ON [PRIMARY]

INSERT INTO Test1 VALUES(1, ‘Bob’,'Smith’)
INSERT INTO Test1 VALUES(2, ‘Dave’,'Jones’)
INSERT INTO Test1 VALUES(3, ‘Karen’,'White’)
INSERT INTO Test1 VALUES(1, ‘Bob’,'Smith’)
INSERT INTO Test1 VALUES(4, ‘Bobby’,'Smita’)

select identity(int,1,1) as SlNo,* into #temp from Test1

DELETE
FROM #temp
WHERE SlNo NOT IN
(
SELECT MAX(SlNo)
FROM #temp
GROUP BY ID,FirstName,lastname
)

drop table test1

select * into test1 from #temp

alter table test1 drop column SlNo

select * from test1 order by id

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between writing data to mirrored drives versus raid5 drives

934


What will be the maximum number of index per table?

1008


How to get a list of columns in a view using "sys.columns" in ms sql server?

994


What do you understand by mirroring and mention the advantages of the mirroring?

1068


Can we take the full database backup in log shipping?

955


What are the new features in SQL Server 2005 when compared to SQL Server 2000?

1166


What are the different types of upgrades that can be performed in sql server?

1177


What are various ways to enhance the ssrs report?

986


plss anybody specify tha constrian management system in dbms

2154


Write a SQL command to insert and update only a particular field?

1115


How do I create a trace in sql server?

1048


What are types of scd? : sql server analysis services, ssas

1017


what are the Prerequisites for Replication?

11354


How to override dml statements with triggers?

1191


What is normalization of database? What are its benefits?

1028