原表如下:
id   address   phone
33   shenzhen  86023747
36   guangzhou 82536565
33   shenzhen  86023747
33   shenzhen  86023747
36   guangzhou 82536565
33   shenzhen  86023747
38   dalian    26835692
新表如下:
33   shenzhen  86023747
36   guangzhou 82536565
38   dalian    26835692

解决方案 »

  1.   

    select distinct * from 表
      

  2.   

    select distinct * into 新表名称 from 原来的表
    drop table 原来的表
      

  3.   

    不能使用distinct提示错误
    信息大致意思为不能对text,ntext,image数据进行比较
      

  4.   

    你哪个字段是text,ntext,image类型的?
      

  5.   

    select * into newtable from oldtable where  id  in(select distinct id from oldtable)
    drop oldtable没经过测试~~~
      

  6.   

    忠心感谢热心的Owl_xiang(紫香)
    我测了,新表数据仍然重复
      

  7.   

    if exists(select * from sysobjects where id=object_id('oldtable') and xtype='u')
      drop table oldtable
    go
    if exists(select * from sysobjects where id=object_id('newtable') and xtype='u')
      drop table newtable
    go
    create table oldtable([id] int,address varchar(20),phone varchar(20))
    insert into oldtable select 33,'shenzhen','86023747'
    union all select 36,'guangzhou','82536565'
    union all select 33,'shenzhen','86023747'
    union all select 33,'shenzhen','86023747'
    union all select 36,'guangzhou','82536565'
    union all select 33,'shenzhen','86023747'
    union all select 38,'dalian','26835692'
    go
    create table newtable([id] int,address varchar(20),phone varchar(20))
    go
    insert into newtable select distinct * from oldtable
    drop table oldtable
    select * from newtable
      

  8.   

    select distinct * into newtable from 数据库.dbo.oldtable
    然后删除oldtable
      

  9.   

    select col1 , col2 ,col3 into newtab from t
    group by col1 , col2 ,col3 
    drop table t
      

  10.   

    用zjdyzwx(十一月猪)的方法难道不行吗,就用Group by呀楼主。
      

  11.   

    --BEGIN
    SELECT NumID = IDENTITY(int, 1, 1),*
    INTO #NewTable
    FROM OldTableSELECT MAX(NumID) AS NumID,id
    INTO #SAVEIDTABLE
    FROM NewTable
    GROUP BY idDELETE FROM #NewTable
    WHERE NumID NOT IN (SELECT NumID FROM #SAVEIDTABLE)SELECT * FROM #NewTableDROP TABLE #NewTable
    DROP TABLE #SAVEIDTABLE
    --OVER--是这个意思么?
      

  12.   

    所有字段值一样,健信息不足sql自己都无法区分你要删除哪条你能删的掉吗?
      

  13.   


    select address  , phone from table group by address  , phone
      

  14.   

    select (select top 1 from table1 where phone = T1.phone and  address= T1.address),address  ,phone from table T1 group by address  , phone