with x as (select *,rn = row_number()
over(PARTITION BY OrderNo,item order by OrderNo)
from #temp1)
select * from x
where rn > 1
u kunt duplicaten verwijderen door de select-instructie te vervangen door
delete x where rn > 1