求删除表中重复记录的sql语句!!!

wallis 2002-07-25 09:48:15
求删除表中重复记录的sql语句!!!
...全文
153 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
愉快的登山者 2002-07-25
  • 打赏
  • 举报
回复
select distinct * into #temptable from tablename
delete tablename
go
insert into tablename from select * from #temptable
go

愉快的登山者 2002-07-25
  • 打赏
  • 举报
回复
select distinct * into #temptable from tablename
delete tablename
go
insert into tablename from select * from #temptable
go
OpenVMS 2002-07-25
  • 打赏
  • 举报
回复
前面太多这样的帖子,可惜网络太慢
假使表中只有name,num2字段
delete a
from #t1 a
where exists(select name,num from #t1 where name=a.name and num=a.num group by name,num having count(*)>1)
Yang_ 2002-07-25
  • 打赏
  • 举报
回复
select distinct * into temptable from tablename
go
truncate table tablename
go
insert tablename
select * from temptable
go
drop table temptable
go

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧