all posts

Removing duplicate rows from SQL Server table

Published to Blog on 28 Aug 2006

I had a need to remove duplicate rows from a SQL Server table this morning and found this incredibly easy way to do so on the SQL Team site:

select distinct *
into #holding
from dup_authors


truncate table dup_authors

insert dup_authors
select *
from #holding

drop table #holding
 

SQL Team is a great site for finding solutions for those unusual queries that pop up from time to time.


Dan Hounshell
Web geek, nerd, amateur maker. Likes: apis, node, mobile, motorcycles, watches, food, Nashville, Savannah, Cincinnati and family. Dislikes: mean people
Dan Hounshell on Twitter