删除重复只留一条

select identity(int,1,1) as autoID,* into #Tmp from research_info WHERE FILE_ID IN(
SELECT FILE_ID FROM research_info WHERE TITLE IN (
select TITLE from research_info GROUP BY TITLE HAVING COUNT(TITLE)>1
))
select min(autoID) as autoID into #Tmp2 from #Tmp group by TITLE
select * from #Tmp where autoID in(select autoID from #tmp2)
DELETE FROM filecontent WHERE FILE_ID IN (select FILE_ID from #Tmp where autoID NOT in(select autoID from #tmp2))

你可能感兴趣的:(删除)