alter table 表 add  newfield int identity(1,1)delete 表
where newfield in(
 select min(newfield) from 表 group by 除newfield外的所有字段
                     )alter table 表 drop column newfield

解决方案 »

  1.   

    to:pengdali(大力 V2.0) 谢谢
    我想问一下
    有没有像distinct 这样的关键字 ,只删出一条,而不是全删除
      

  2.   

    必需加主键如大力或者把数据放到有主键的临时表,如:select identity(int,1,1)id,* into #temp from Yourtable
    然后再删除
      

  3.   

    使用游标
    DELETE FROM 表 WHERE CURRENT OF current_cursor
      

  4.   

    好像没有 ;)
    如果是这样 就是删除重复记录,只保留一条
    delete 表
    where newfield not in(
     select min(newfield) from 表 group by 除newfield外的所有字段
                         )