How to delete exactly duplicate records from a table?



How to delete exactly duplicate records from a table?..

Answer / Mohammad Shavab

You can delete exact duplicate records from a table using the ROW_NUMBER() window function in SQL Server. Here is an example query: DELETE FROM [YourTable] WHERE ROW_NUMBER() OVER (ORDER BY [Column1], [Column2] ...) = ROW_NUMBER() OVER (PARTITION BY [Column1], [Column2]... ORDER BY [Column1], [Column2]...). Replace [YourTable] and the column names with those in your actual table.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?

1 Answers  


Can we call a function that has out parameter in select statement

0 Answers   Nagarro,


What does executeupdate return?

1 Answers  


How to enter date and time literals in ms sql server?

1 Answers  


How to store and query spatial data?

1 Answers  


How many categories of functions based their return modes?

1 Answers  


What is dml command?

1 Answers  


How to optimize stored procedure optimization?

1 Answers  


Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)

1 Answers  


Which are ddl commands?

1 Answers  


What is deadlock and how to avoid the deadlocks.

3 Answers   TCS, Wipro,


How to execute a sql statement using mssql_query()?

1 Answers  


Categories