select distinct * into # from 表 truncate table 表 insert into 表 select * from # drop Table #
create table tpeat(a varchar(20),b varchar(20)) insert into tpeat select 'aa','bb' insert into tpeat select 'aa','bb' insert into tpeat select 'aa','bb' insert into tpeat select 'c','c' insert into tpeat select 'c','d' insert into tpeat select 'd','s' insert into tpeat select 'd','s'create table #a(a varchar(20),b varchar(20))insert into #a select distinct * from tpeat delete tpeat insert into tpeat select * from #a drop table #adrop table tpeat --删除测试用例所影响的行数为 4 行) (所影响的行数为 7 行) (所影响的行数为 4 行)
飘雪的这个不错 select distinct * into # from 表 truncate table 表 insert into 表 select * from # drop Table # 但是我有个问题:如果数据量大的话应该如何处理会快点?====CSDN 小助手 V2.0 2005年10月16日发布==== CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件 界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/10/16/504620.aspx 下载:http://szlawbook.com/csdnv2/csdnv2.rar为神六喝彩,向所有科技工作者致敬! 拒绝日货。
如果表t1的字段只有a2和a3的话,zlp321002(飘过) 的方法是最省事的.
into 临时表(*) select a2,a3 from 表 group by a2,a3 having count(*)>1 delete 表 where a2+a3 in (select a2+a3 from 表 group by a2,a3 having count(*)>1 ) insert into 表 select * from 临时表 drop Table 临时表
select distinct * into # from 表 truncate table 表 insert into 表 select * from # drop Table # 是个好方法, UP
begin select distinct * into #js from js delete from js insert into js select * from #js if @@error <>0 rollback drop table #js end
begin select distinct * into #表 from 表 delete from 表 insert into 表 select * from #表 if @@error <>0 rollback drop table #表 end
Create table temp_001(sec1 varchar(10),sec2 varchar(10)) insert into temp_001 select 'aa','bb' union all select 'aa','bb' union all select 'aa','bb' union all select 'c','c' union all select 'c','d' union all select 'd','s' union all select 'd','s' select * from temp_001 select distinct * from temp_001 drop table temp_001
truncate table 表
insert into 表 select * from #
drop Table #
insert into tpeat select 'aa','bb'
insert into tpeat select 'aa','bb'
insert into tpeat select 'aa','bb'
insert into tpeat select 'c','c'
insert into tpeat select 'c','d'
insert into tpeat select 'd','s'
insert into tpeat select 'd','s'create table #a(a varchar(20),b varchar(20))insert into #a select distinct * from tpeat
delete tpeat
insert into tpeat select * from #a
drop table #adrop table tpeat --删除测试用例所影响的行数为 4 行)
(所影响的行数为 7 行)
(所影响的行数为 4 行)
select distinct * into # from 表
truncate table 表
insert into 表 select * from #
drop Table #
但是我有个问题:如果数据量大的话应该如何处理会快点?====CSDN 小助手 V2.0 2005年10月16日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/10/16/504620.aspx
下载:http://szlawbook.com/csdnv2/csdnv2.rar为神六喝彩,向所有科技工作者致敬!
拒绝日货。
select a2,a3 from 表 group by a2,a3 having count(*)>1 delete 表 where a2+a3 in (select a2+a3 from 表 group by a2,a3 having count(*)>1 )
insert into 表 select * from 临时表
drop Table 临时表
truncate table 表
insert into 表 select * from #
drop Table #
是个好方法, UP
select distinct * into #js from js
delete from js
insert into js select * from #js
if @@error <>0
rollback
drop table #js
end
select distinct * into #表 from 表
delete from 表
insert into 表 select * from #表
if @@error <>0
rollback
drop table #表
end
http://zhangjidong.cnblogs.com/archive/2005/08/02/205319.html
select distinct * from table1
insert into temp_001
select 'aa','bb'
union all
select 'aa','bb'
union all
select 'aa','bb'
union all
select 'c','c'
union all
select 'c','d'
union all
select 'd','s'
union all
select 'd','s'
select * from temp_001
select distinct * from temp_001
drop table temp_001