2011-11-27 4 views
0

는 중복 행을

ID Date 

001 23/02/2009 
001 24/02/2009 
001 24/02/2009 
002 25/02/2009 
002 25/02/2009 
... 

을 삭제하는 방법은 위의 테이블에서 중복 행을 삭제합니다.

예상 출력

ID Date 

001 23/02/2009 
001 24/02/2009 
002 25/02/2009 
... 

쿼리 도움이 필요

내가 어디서 얻었

답변

2

기억 할 수 없습니다,하지만 난 테이블에서 중복을 제거하려면이 SQL을 사용하는 데 사용 :

 
begin tran deduplicate 

select DISTINCT * 
into #temp 
from mytable 

truncate table mytable 

insert mytable 
select * 
from #temp 

select * from mytable 

drop table #temp 
commit tran deduplicate 
관련 문제