日期:2014-05-18 浏览次数:20592 次
select distinct * into # from tb go truncate table tb go insert tb select * from # go drop table #
------解决方案--------------------
create table test(username varchar(20),department varchar(20)) insert test select 'roy','com' union all select 'Alwin','UUDI' union all select 'roy','com' go delete test where username in (select username from test group by username having count(*)>1) select * from test username department -------------------- -------------------- Alwin UUDI (所影响的行数为 1 行)
------解决方案--------------------
create table test(username varchar(20),department varchar(20)) insert test select 'roy','com' union all select 'Alwin','UUDI' union all select 'roy','com' go --drop table test delete test where username in (select username from test group by username,department having count(*)>1) select * from test username department -------------------- -------------------- Alwin UUDI (所影响的行数为 1 行)
------解决方案--------------------