清理重复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

posted on 2009-06-22 02:44  chuncn  阅读(459)  评论(0编辑  收藏  举报

导航