Write a sql query to delete duplicate records from a table called table1



Write a sql query to delete duplicate records from a table called table1..

Answer / Vipin Sonkar

You can delete duplicate rows from a table in SQL Server using the ROW_NUMBER() window function:

```sql
WITH cte AS (
SELECT *,
ROW_NUMBER() OVER(ORDER BY YourColumn) as rownum
FROM Table1
)
DELETE FROM cte WHERE rownum > 1

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is bcnf normalization form?

1 Answers  


What is index, cluster index and nonclustered index?

1 Answers  


What is the difference between dropping a database and taking a database offline?

1 Answers  


Define compound operators?

1 Answers  


What is 'write-ahead log' in sql server 2000 ?

1 Answers  


How will you decide the active and passive nodes?

1 Answers  


What is an identity?

1 Answers  


What is the difference between a Application Server and a Database

3 Answers   Oracle,


Why are views required in the sql server or in any other database?

1 Answers  


How do I change my passwords (database, LDAP, and so on) without causing an outage?

1 Answers   IBM,


one of my database size is 2gb and Unrestricted Growth for Data file up to 10%.But every day after day I am getting Primary Data file is full 99.999 please take appropriate actions.Why it is? Even disk space is also not full,but still I am getting the alerts.

1 Answers   Cognizant,


Explain what is row_number function?

1 Answers  


Categories