34,590
社区成员
发帖
与我相关
我的任务
分享
select distinct * into # from tableName
truncate tableName
insert tableName select * from #
drop table #
create table test
(
PKID int primary key identity(1,1),
Name varchar(30)
)
insert into test select '张三' union all select '李四' union all select '李四'
select * from test
delete test where PKID not in (select min(PKID) from test group by name)
select * from test
delete a
from table1 a
where not exists( select 1 from table1 where col = a.col and id > a.id)
select distinct * into # from 表
delete 表
insert into 表 select * from #
drop table #