用一下Group by
select min(field1),min(field2),... from Table where xxxx group by field1,field2如果只有一条数据的话,min就是他自己,如果有重复,min也是自己,但是只会出现一次
select min(field1),min(field2),... from Table where xxxx group by field1,field2如果只有一条数据的话,min就是他自己,如果有重复,min也是自己,但是只会出现一次
select distinct 字段名,, into New表 from 表
删掉旧表
truncate table yourtable
insert into yourtable select * from #t1
drop table #t1
一个的话用
select distinct * into #t1 from yourtable
truncate table yourtable
insert into yourtable select * from #t1
drop table #t1
多个的话用select min(field1),min(field2),... into temp1 from Table1 where xxxx group by field1,field2
alter table 你的表 add id int identity(1,1)
godelete 你的表
from 你的表 a left join(
select id=min(id) from 你的表 group by NUM,BOOKNAME,PRICE
)b on a.id=b.id
where b.id is null
goalter table 你的表 drop column id