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 use of except clause? How does it differ from not in clause?

962


User wants only to display only pdf as export option in report manager. How to achieve this?

247


What is meant by indexing?

939


Is sql server difficult to learn?

863


What is an index in sql?

959


How much is a sql server license?

900


Write a Select Query to display title for each group of records, which are collected with Compute Clause? Like titlefield column-A column-B ..... ..... ..... Sum ... titlefield column-A column-B ..... ..... ..... Sum ...

1987


What are indexes in ms sql server?

996


What is meant by dirty read?

950


what number files will a information contain in SQL Server? How many forms of information files exist in SQL Server? How many of those files can exist for a single database?

985


How you can get a list of all the table constraints in a database?

906


Explain concepts of analysis services?

891


Explain what are the different index configurations a table can have?

1037


How to write a query with an inner join in ms sql server?

997


Can you tell me about the concept of ER diagrams?

1018