删除重复数据

 

代码
declare @max integer,@hotel_id integer,@room_name nvarchar(100)

declare cur_rows cursor local for select room_name,hotel_id,count(*) from hotel_room group by hotel_Id,room_name having count(room_name)>1


open cur_rows

fetch cur_rows into @room_name,@hotel_id,@max

while @@fetch_status=0

begin

select @max = @max -1

set rowcount @max

delete from hotel_room where hotel_id = @hotel_id and room_name=@room_name

fetch cur_rows into @room_name,@hotel_id,@max

end

close cur_rows

set rowcount 0

 

 

 

posted on 2010-04-26 17:52  merrick  阅读(84)  评论(0)    收藏  举报