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 to list all columns in a table using odbc_columns()?
What is merge?
Write a query for primary key constraint with identity key word?
How we can compare two database data?
Explain what you mean by 3 tier architecture.
What are approximate numeric data types in ms sql server?
Define a cross join?
What are Row versions of DataRow?
What does select 1 mean?
What happens if you add a new index to large table?
Why we need to use secondry database file? though, we can do same work using primary database file also.
What are pessimistic lock and optimistic lock?
What is a cursor, index in sql?
Explain concepts of analysis services?
Where can you add custom error messages to sql server?