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

How important do you consider cursors or while loops for a transactional database?

1009


How sql server executes a statement with nested subqueries?

1088


Can you explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?

1034


What is the downside of using udf?

1158


What is extended stored procedures?

1022


What are the different types of locks in the database?

972


Why should you use or avoid select * statements?

1071


What is best institute to Learn DotNET And SQL in chennai?

2219


Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?

1448


What is a primary key?

996


Can you create a logon trigger in sql server 2005 express edition?

1117


What is b tree index?

963


Explain table valued parameters in sql server? Why tvp used?

1065


How do I edit a stored procedure in sql server?

968


What is bcnf normalization form?

1158