Here is an example of how to remove duplicates from a temporary table in MSSQL.
create table marxBrothers (
ident int IDENTITY,
Name varchar(32)
)
go
insert marxBrothers (Name)
select 'Groucho Marx' UNION ALL
select 'Harpo Marx' UNION ALL
select 'Chico Marx' UNION ALL
select 'Groucho Marx' UNION ALL
select 'Harpo Marx' UNION ALL
select 'Chico Marx' UNION ALL
select 'Zeppo Marx' UNION ALL
select 'Gummo Marx' UNION ALL
select 'Zeppo Marx'
select * from marxBrothers
delete marxBrothers
from marxBrothers,
(
select min(ident) as minIdent, name
from marxBrothers m
group by name
having count(1) > 1
) as derived
where marxBrothers.name = derived.name
-- This 'and' makes sure that one of the duplications is not deleted,
-- remove it if you do not want one copy of the duplication to remain.
and ident > minIdent
select * from marxBrothers...