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

Write a query to delete duplicate records in SQL SERVER

Answer Posted / sunil

CREATE TABLE [dbo].[DupTable](
[Name] [nchar](10) NOT NULL,
[Age] [int] NOT NULL
) ON [PRIMARY]

-- Insert the duplicate data into the table...



Select * from DupTable
go

with Emp AS
(
Select Name,Age, ROW_NUMBER() over (order by Name) as
RowNumber FROM DupTable
)
Delete t1 From Emp as T1, Emp as T2
where T1.Name = T2.Name AND T1.Age= T2.Age and T1.RowNumber
> T2.RowNumber
go

Select * from DupTable
go

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of indexes?

998


How we can compare two database data?

875


Can we use where and having clause together?

980


What is the usage of sign function?

1040


Explain the difference between function and stored procedure?

900


Who developed sql server?

877


Can we call future method from queueable?

996


What is transact-sql language?

1008


How do I completely remove sql server instance?

1026


Which event (check constraints, foreign key, rule, trigger, primary key check) will be performed last for an integrity check?

941


What is row_number()?

934


How many types of triggers in sql server?

972


Explain can SSRS reports Cache results?

149


Which are the olap features?

907


Explain nested stored procedure. Syntax and an example for create nested stored procedure?

884