Wen/Xiachong
Nightmare for Developers--delete duplicate records
Presumably every developer has had a similar experience, and when querying or counting the database, the query and statistic results are inaccurate due to duplicate records in the table. The solution to this problem is to delete the duplicate records and keep only one of them.
In SQL Server, in addition to manually deleting a table with more than 10 records, implementing a delete duplicate is typically a piece of code that is checked by a row of cursor methods, deleting duplicate records. Because this method requires traversal of the entire table, it is still possible for the number of records in the table to be very large, and if the data for a table is up to millions, it is a nightmare to delete with the cursor method because it will take a long time to execute.
Four axe--easy to eliminate duplicate records
There is a simpler way to do this in SQL Server, which does not require cursors, as long as a simple INSERT statement can be used to remove duplicate records. In order to be clearly stated, we first assume that there is a product information table products, whose table structure is as follows:
Tip: Deleting duplicate records in the above method depends on the field you select when you create a unique index, and in the actual course of action you must first confirm that the unique indexed field you created is correct to avoid deleting useful data.