删除数据库中相同学号的学生(全部)

liuminkuaile 2003-07-29 08:02:02
我想删除学生信息表中的所有学号相同的学生记录!不知如何写SQL语句!
...全文
290 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zclxyh 2003-07-29
  • 打赏
  • 举报
回复
select distinct * into #temp from 表
truncate table 表
select * into 表 from #temp
drop table #temp
pengdali 2003-07-29
  • 打赏
  • 举报
回复
删除重复,留下一条:

select distinct * into #temp from 表
truncate table 表
select * into 表 from #temp
drop table #temp
pengdali 2003-07-29
  • 打赏
  • 举报
回复
Delete 表 where exists (Select studentID from 表 tem group by 所有列 having sum(1)>1 and tem.所有列=所有列)
liuminkuaile 2003-07-29
  • 打赏
  • 举报
回复
Delete yourTable where studentID in (Select studentID from yourTable group by studentID having count(*) > 1)
好象不行呀!
txlicenhe 2003-07-29
  • 打赏
  • 举报
回复
Delete yourTable where studentID in (Select studentID from yourTable group by studentID having count(*) > 1)
goodboycwy 2003-07-29
  • 打赏
  • 举报
回复
insert into new_table select distinct * from old_table
然后把new_table 重新命名为 old_table
woyaofengle 2003-07-29
  • 打赏
  • 举报
回复
delete from table where exists (select studentID from tabel group by 1 having count(*)>1 )

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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