with tb(a,id,pwd,home) as ( select row_number() over(partition by id,pwd,home order by id)a,* from 表名 ) delete tb where a>2
单纯从数据来说:直接select distinct * from 表 不就可以咯?
然后把这些数据先存到一个临时表,然后turncate源表,再把数据插回去。方法有多种,
1 :首先查找出重复的数据并且过滤掉 ,然后复制到一张临时表里面 select * into temp from (select distinct* from tab) as a 2:删除之前的原始表 drop table tab 3:把临时表里面的数据再复制到原始表里(注:这里的原始表意义上是和之前的那个表的表名一样) select * into tab from temp
select * into temp from (select distinct* from tab) as a 最后面那个a 是干啥的啊
步骤1:select distinct * into #t from tb 步骤2:truncate table tb 步骤3:insert into tb select * from #t 步骤4:drop table #t
select * into #a from txtinsert into txt select distinct id,pdw,home from #adrop table #a
with tb(a,id,pwd,home) as
(
select row_number() over(partition by id,pwd,home order by id)a,* from 表名
)
delete tb where a>2
select * into temp from (select distinct* from tab) as a
2:删除之前的原始表
drop table tab
3:把临时表里面的数据再复制到原始表里(注:这里的原始表意义上是和之前的那个表的表名一样)
select * into tab from temp
最后面那个a 是干啥的啊
步骤2:truncate table tb
步骤3:insert into tb select * from #t
步骤4:drop table #t
select * into #a from txtinsert into txt
select distinct id,pdw,home from #adrop table #a
这里的a是干嘛的啊