2011-11-27 43 views
0

表1如何刪除重複的行

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