查询重复数据已经可以了
select 字段1,字段2,count(*) from Product group by 字段1,字段2 having count(*) > 1删除重复数据出现问题,等待求解.delete from 表 a where 字段1,字段2 in(select 字段1,字段2,count(*) from 表 group by 字段1,字段2 having count(*) > 1)提示错误如下服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: 'a' 附近有语法错误。希望高人指点一二.谢谢

解决方案 »

  1.   

    where 字段1,字段2 in只能是 字段1 in () and 字段2 in () 
      

  2.   

    delete T from 表a as T where exists(select 1 from 表a where 字段1=t.字段1 and 字段2=t.字段2 and 主健>T.主健)
      

  3.   

    ;with C 
    as
    (select * ,row=row_number()over(partition by 字段1,字段2 order by 字段1) from  表a
    )
    delete c where row>1
    ---SQL2005以上版本
      

  4.   

     delete a from 表A a
     where exists( select 1 from 表A a where 字段1=a.字段2 and 字段2=a.字段2 and id<>a.id)
      

  5.   

     delete from 表 a where checksum(字段1,字段2) in
    (select check(字段1,字段2) from 表 group by 字段1,字段2 having count(*) > 1)
      

  6.   

    本帖最后由 roy_88 于 2011-02-27 11:08:39 编辑
      

  7.   

    字符类型时建议用BINARY_CHECKSUM--这是区分字母大小写的
      

  8.   


    如:ID列在表中唯一的
    create table ta(ID int identity primary key,Name nvarchar(10))\
    go
    insert ta select 'A'
    insert ta select 'A'
      

  9.   

    where 字段1 in () and 字段2 in ()
      

  10.   

     1_ID>T.1_ID这样算是主建吗?
      

  11.   

    delete a from 表A a
     where exists( select 1 from 表A a where 字段1=a.字段2 and 字段2=a.字段2 and 1_ID<>a.1_ID)
      

  12.   


    delete a from Product a
    where exists( select 1 from Product a where Title=a.User and User=a.User and 1_ID<>1_ID)(所影响的行数为 0 行)
    没有删除重复的阿
      

  13.   

    参照
    处理表重复记录(查询和删除)
    http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html