Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Peter Petrov,
Here is another "deleting duplicate records" script, this time in-place. It exploits the ability to relatively easily add and drop a uniqueidentifier column to a table. The term "must-be-unique columns" refers to the set of columns that have to have a unique combination of values (natural primary key candidate for the table). The DELETE statement is quite generic and the comments suggest the changes needed for any other table. In addition, you obviously have to replace "MyTab" with the name of your table. Note: The "DELETE" statement is designed and formatted in order to extend its usage - replacing "DELETE t" with "SELECT t.*" will return the records that will be deleted.
delete duplicates from table with all columns with datatype varchar()
delete first 10rows from the table without knowing column names
Deletion of records
how can i avoid a column in a table from getting deleted?