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 / rajnish kumar pandey

WITH TempTable(Col1, Col2, DuplicateCount)
AS
(
SELECT Col1, Col2,
ROW_NUMBER() OVER(PARTITION BY id, roles ORDER BY id) AS
DuplicateCount
FROM MainTable
)
DELETE
FROM TempTable
WHERE DuplicateCount > 1
GO

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is 1nf 2nf and 3nf?

892


Can you explain the disadvantages/limitation of the cursor?

992


What is the use of floor function in sql server?

1086


how to create a scrollable cursor with the scroll option? : Sql server database administration

1097


What does truncate do?

943


what are different types of backups available in sql server? : Sql server database administration

942


Differentiate between sql temp table vs table variable?

887


Are connections to sql server encrypted?

1008


Find nth lowest salary or get nth lowest salary?

1029


Why the trigger fires multiple times in single login?

1216


What is the difference between stored procedure and user defined functions?

1195


What are logical/boolean operations in ms sql server?

1051


What happens if the update subquery returns multiple rows in ms sql server?

1127


What is relationship? What number of sorts of relationship are there?

1143


Can a synonym name of a table be used instead of a table name in a select statement?

1040