[Script of May 7] Delete duplicate m-1 rows in a table whose first n columns are the same (T-SQL)

Script Download: Deleteduplicaterows.zip
https://gallery.technet.microsoft.com/scriptcenter/Delete-duplicate-m-1-rows-ab1c9525

This T-SQL script sample shows how to delete some duplicate rows in a table whose first 3 columns are the same and keep only one row. You can write a script according to your request by referencing this script.

Some people ask for a script to delete duplicate rows and keep only one row in a table. This T-SQL script sample will show you by creating a new table TestTable to imitate your table and a temporary table #TempTable. All the duplicate data will be stored in the temporary table. After executed, it will generate 2 tables, one to show you the duplicate data and a table to show the final result. 

image image
image

You can find more All-In-One Script Framework script samples at https://aka.ms/onescriptingallery