怎么删除数据库里的有两条一样的记录的其中一条,保留一条?

qyc0921 2003-07-13 01:27:54
怎么删除数据库里的有两条一样的记录的其中一条,保留一条?
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-07-13
  • 打赏
  • 举报
回复
或:

select distinct * into #temp from 表
truncate table 表
insert 表 select * from #temp
drop table #temp
pengdali 2003-07-13
  • 打赏
  • 举报
回复
alter table 表 add newfield int identity(1,1)

delete 表
where newfield not in(
select min(newfield) from 表 group by 除newfield外的所有字段
)

alter table 表 drop column newfield

34,576

社区成员

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

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