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
How important do you consider cursors or while loops for a transactional database?
How sql server executes a statement with nested subqueries?
Can you explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?
What is the downside of using udf?
What is extended stored procedures?
What are the different types of locks in the database?
Why should you use or avoid select * statements?
What is best institute to Learn DotNET And SQL in chennai?
Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?
What is a primary key?
Can you create a logon trigger in sql server 2005 express edition?
What is b tree index?
Explain table valued parameters in sql server? Why tvp used?
How do I edit a stored procedure in sql server?
What is bcnf normalization form?