【sqlserver】删除重复性数据

1sql语句:

while 1=1 - - 启动无穷循环

begin

delete top(1) from aaa(表名) - - 一次删除一行数据

where myname in (select myname from aaa

group by myname

having count(*)>1) --仅删除重复数据

if @@ROWCOUNT=0 BREAK - -判断最近删除行数

end

测试

select * from aaa

2 select distinct myname from aaa

你可能感兴趣的:(sqlserver)