解决方案 »

  1.   

    换一个思路,把没有重复的记录select出来,再删除原来的表。
      

  2.   

    换一种思路,把没重复的记录Select出来,再删除原来的表,
      

  3.   

    delete table    from table,   (select id,count(*) from table group by id having count(*)>1) as ar 
        
       where table.id=ar.id
      

  4.   

    好久没写过SQL语句了:(  也不知对不对姑且一试,错了勿怪
      

  5.   

    铁诺:好:)好久没写过SQL语句了,昨天写一个最简单的update居然错了两个地方:(少写了表名,少写了set,唉,想不到我忘东西这么快.....
      

  6.   

    假如你要检查id列的重复行。
    delete from tablename where id in (select id from tablename group by id having count(id)>=2)
    试试,看看对不对
      

  7.   

    create tmp_table as
     select distinct field1,field2... from table_a;
    drop table table_a;
    create table_a as select * from tmp_table;
    drop table tmp_table;
      

  8.   

    oracle:
    delete from mytable t1 where rowid<>(select max(rowid) from mytable t2 where t1.dupfield=t2.dupfield)
    sqlserver:
    create table #mytb (f1 int,dupfield,  .....)
    create index idx_mytb on #mytb(dupfield) WITH IGNORE_DUP_KEY
    insert into #mytb select * from mytable
    truncate table mytable
    insert into mytable from #mytb
      

  9.   

    用于access,sql server的,是所有字段都相同,而且里面有memo字段不能用distinct,否则怎么会这么麻烦。
      

  10.   

    要知道你那个字段是重复的才好写sql
      

  11.   

    select distinct column1,column2,...,cast(memo列 as varchar(8000)) as memo列 
    into #tmptable from yourtable
    truncate table yourtable
    insert into yourtable from #tmptable
      

  12.   

    create table (a nuber, b number);declare
    a1 number;
    b1 number;
    x rowid;
    cursor a is select rowid,a ,b from test;
    begin
    open a;
    loop
    fetch a into x, a1,b1;
    delete from test where a=a1 and b=b1 and not(rowid=x);
    exit when a%notfound;
    end loop;
    close a;
    end;
      

  13.   

     同意Michaelyfj(难怪!)的观点,这种方法即简单又实用。
      

  14.   

    declare
    a1 number;
    b1 number;
    x rowid;
    cursor a is select rowid,a ,b from test;
    begin
    open a;
    loop
    fetch a into x, a1,b1;
    delete from test where a=a1 and b=b1;
    insert into test values (a1,b1);
    commit;
    exit when a%notfound;
    end loop;
    close a;
    end ;
      

  15.   

    小可不才,create table b as select distinct * from a;
    再用b代替a
      

  16.   

    逻辑变量pdxtzd 初值为true,判断记录是否相等
    datastore a
    a = create datastore
    a.dataobject="dbf"
    a.settransobject(sqlca)
    a.retrieve()
    datastore b
    b = create datastore
    b.dataobject="dbf"
    b.settransobject(sqlca)
    b.retrieve()
    for i=1 to a.rowcount()
       for j=1 to b.rowcount()
           if a.getitemX(i,"字段1")<>b.getitemX(j,"字段1") then pdxtzd = false
           if a.getitemX(i,"字段2")<>b.getitemX(j,"字段2") then pdxtzd = false
           if a.getitemX(i,"字段3")<>b.getitemX(j,"字段3") then pdxtzd = false
           if a.getitemX(i,"字段4")<>b.getitemX(j,"字段4") then pdxtzd = false
    .......
           if a.getitemX(i,"字段n")<>b.getitemX(j,"字段n") then pdxtzd = false       end if
        next
    if pdxtzd = true then a.deleterow(i)
    next
    a.update()
      

  17.   

     我遇到这种情况一般是用一个比较笨的方法,就是用acess 把这个表导进来,加上一个自动编号的字段,再把重复的行删去,再导回去
      

  18.   

    到HTTP://WWW.ORADB.NET上去看看吧,有你要的东西。
      

  19.   

    看表中的重复行是完全一样还是只有某些字段一样.如果完全一样.建议采用Select语句的distinct关键字.
      

  20.   

    一条SQL语句只能建一个新的表。
    SELECT DISTINCT a.* INTO b FROM a
    DROP TABLE a
    SELECT b.* INTO a
      

  21.   

    http://www.csdn.net/Expert/topic/431/431723.shtm
    欢迎来讨论
      

  22.   

    SELECT DISTINCT * INTO b FROM a
    insert from b INTO a 
    DROP TABLE b
      

  23.   

    Oracle:
    Delete From table1 a Where a.rowid != (Select max(rowid) from table1 b where a.col1 = b.col1 and a.col2 = b.col2 and ...);   
      

  24.   

    SELECT MAX(COL1),MAX(COL2),MAX(COL3) FROM TABLEA group by col1,col2 出所有单行,写进新的表就行了。