摘要: SQL去掉重复记录第一种,数据全部重复,如下图:需要得到以下的结果:删除重复的记录(重复记录保留1条),可以按以下方法删除1 seleet distinct * into #Tmp from 表名2 3 drop table 表名4 5 select * into 表名 from #Tmp6 7 drop table #Tmp第二种,数据部分字段重复,ID不重复 ,如下图:需要得到以下结果:下面的语句可以达到要求:delete Comment where CommentID not in(SELECT MAX(CommentID) AS id FROM Comment GROUP BY Com 阅读全文
posted @ 2012-10-17 09:51 日月当空 阅读(256) 评论(0) 推荐(0)