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
What is 1nf 2nf and 3nf?
Can you explain the disadvantages/limitation of the cursor?
What is the use of floor function in sql server?
how to create a scrollable cursor with the scroll option? : Sql server database administration
What does truncate do?
what are different types of backups available in sql server? : Sql server database administration
Differentiate between sql temp table vs table variable?
Are connections to sql server encrypted?
Find nth lowest salary or get nth lowest salary?
Why the trigger fires multiple times in single login?
What is the difference between stored procedure and user defined functions?
What are logical/boolean operations in ms sql server?
What happens if the update subquery returns multiple rows in ms sql server?
What is relationship? What number of sorts of relationship are there?
Can a synonym name of a table be used instead of a table name in a select statement?