方法一:
delete from tb_channel a where a.rowid in
(select max(b.rowid) from tb_channle b
where a.policyno=b.policyno and a.classcode=b.classcode);
——這一辦法在數據記錄超過10萬時一般都會變得很慢。
方法二:
--建立臨時表,--清空原表,--插回原表,如下例:
create table temp_emp as (select distinct * from employee) ;
truncate table employee;
insert into employee select * from temp_emp;
——這一辦法適用於較大的表的情況。因爲是塊操作,對應於大表效率會好很多
方法三:
--建立新表,--去重複放入,--刪除原表,如下例:
select distinct * into new_table from old_table
order by 主 鍵
drop table old_table
exec sp_rename new_table,old_table;
——這一辦法適用於較大的表的情況。因爲是塊操作,對應於大表效率會好很多