select IDENTITY(int,1,1) as id0,* into #t from tblStyleselect * from #t a where id0=(select min(id0) from #t where StyleNo=a.StyleNo)drop table #t

解决方案 »

  1.   

    select * into #temp1 from tblStyle where 1=2create unique index aaa on #temp1(StyleNo) with (IGNORE_DUP_KEY=ON);insert into #temp1 select * from tblStyledelete from tblStyleinsert into tblStyle select * from #temp1
      

  2.   

    樓上 eru()
    第三句有問題
    insert into #temp1 
    select StyleNo 
      max(c2),
      max(c3),
      max(c4),
      max(c5)
    from tblStyle 
    Group By StyleNo
      

  3.   

    可能我没写清楚,我的意思是重复的删除掉,不是只显示每个StyleNo的第一条。不过我用第一位的语句经过修改实现了,多谢各位,结贴!!