删除重复的,只留一条:alter table 表 add newfield int identity(1,1)delete 表
where newfield not in(
select min(newfield) from 表 group by 你原来的关键字
)alter table 表 drop column newfield
where newfield not in(
select min(newfield) from 表 group by 你原来的关键字
)alter table 表 drop column newfield
这样的话,source_table如果有关键字和dest_table相同的记录,也会进入到dest_table里面么?这样不是违反了数据库关键字的唯一性?BTW:我的关键字是两个字段的组合。
insert into dest_table select * from source_table where 关键字 not in (selct 关键字 from dest_table)
比如说关键字为:A和B
应该写成:
insert into dest_table select * from source_table where A,B not in (selct 关键字 from dest_table)???
这样好像不对的说。