删除(多字段)重复记录

一、删除(多字段)重复记录
IF (SELECT object_ID('tempdb.dbo.#Test'))>0 DROP TABLE #Test

SELECT IDENTITY (INT,1, 1) AS FID, JobID,FlashTime
 INTO #Test
  FROM HFlashCardRecord
  WHERE FlashTime between '2004-11-16' and '2004-11-18'
  ORDER BY Cast(JobID as NUMERIC(18,0)),FlashTime

DELETE FROM #Test WHERE FID IN(
 SELECT MAX(FID) FROM #Test
  GROUP BY FlashTime, JobID HAVING COUNT(FID)>1
)

SELECT * FROM #Test

posted @ 2004-11-17 15:52  D10.天地弦  阅读(618)  评论(0编辑  收藏  举报