如何用SQL删除一个表中重复的一条记录?
我这边只会用SQL查找出来,如:select phonenumber as phonenumber from liantonghao where phonenumber in (select phonenumber from liantonghao as tem group by phonenumber HAVING Count(*)>1 );
怎么删除其中一个就不会啦

解决方案 »

  1.   

    在select 中加 top 1  查出来的就是你要删除的记录
      

  2.   

    --用如下办法
    select distinct * into # from yTableName
      drop table tableName
      select * into tableName from #
      drop table #
      

  3.   

    select * into #t
    from liantonghao truncate table liantonghao insert into liantonghao 
    select * from #t
      

  4.   

    to simonhehe():谢谢你的回复,第一种方法不是我要求的,它只能删除第一个重复的记录,其它的就不行啦,第二种方法可以做得到我的要求,但我这边的这个表非常大,还有其它关联,所以不能删除。
      

  5.   

    唉刚吃饭回来就被simonhehe()  给强了 !