select distinct * from 表

解决方案 »

  1.   

    你的表里只有日期、公司、工程、标号、价格这五个字段吗??如果是的话,就select distinct * from 表不是的话,就select distinct 日期,公司,工程,标号,价格 from 表
      

  2.   

    alter table tablename add sid int identity(1,1) 
    select *
    from tablename a
    where exists(select 1 from tablename where 日期=a.日期 and 公司=a.公司 and 工程=a.工程
                                               and 标号=a.标号 and 价格=a.价格 and id<a.id)alter table tablename drop column sid
      

  3.   

    select * into #t from (select distinct * from tablename)t
    truncate table tablename
    insert into tablename select * from #t
      

  4.   

    Decalre  @日期 datetime,
            @公司 varchar(50),
         @工程  varchar(100),
         @标号  varchar(10),
          @价格  int,
             @i  int
    set @日期='1920/10/01'
     set        @公司 =''
     set     @工程 ='' 
     set     @标号=''  
     set      @价格 =0 
     set         @i=0  
    select  *,bb=0 into  #b from  表
    ----------把表放進臨時表--------
    update #b  set bb=@i,@i=(case when  @日期=日期 and @公司=公司  and @工程=工程  and 
      @标号=标号  and @价格=价格 then @i+1  else 1 end),
      @日期=日期,@公司=公司,@工程=工程,
      @标号=标号,@价格=价格
    -----------------------------------保存唯一
    delete from #b where bb<>1
    ---------------
    truncate table  表   ----把表清空
    insert into 表
    select 日期,公司,工程,标号,价格  from #bdrop table  #b       ---------醫出來
      

  5.   

    xluzhong(打麻将一缺三,咋办?) ( ) 信誉:100  2005-03-17 10:18:00  得分: 0  
     
    -----是對的
      

  6.   

    晕,说的是xluzhong(打麻将一缺三,咋办?)  的
      

  7.   

    create table t([name] nvarchar(10))
    insert into t select 'ralph' union all select 'king'
    union all select 'ralph' union all select 'king'
    goalter table t add id int identity(1,1)
    go
    select * from t
    go
    delete t 
    from t a
    where exists(select * from t where id<a.id and [name]=a.[name])
    go
    select * from t
    go
    alter table t drop column id
    go
    drop table t
    go