Use a temporary table to copy the rows you want to keep in, clean out the
old table with TRUNCATE, and then copy the rows from the temporary table
back into the old table.
SELECT DISTINCT <column_list> INTO #temp FROM old_table
INSERT INTO old_table(<column_list>)
SELECT <column_list> FROM #temp
DROP TABLE #temp
TRUNCATE is a very quick method to clean out a table.
A few minor caveats:
- You need to be a member of dbo, ddl_admin or sysadmin role to use TRUNCATE
- TRUNCATE won't fire triggers.
- You can't ...