去掉ID重复的数据

declare @max integer,@id integer

declare cur_rows cursor local for

select Employee_No,count(*) from Employee group by Employee_No having count(*) > 1

open cur_rows

fetch cur_rows into @id,@max

while @@fetch_status=0

begin

    select @max = @max -1

    set rowcount @max

    delete from Employee where Employee_No = @id

    fetch cur_rows into @id,@max

end

close cur_rows

set rowcount 0

原文地址:https://www.cnblogs.com/onlytiancai/p/1332227.html