删除重复数据

ALTER PROCEDURE [dbo].[Delete_repeat_Data] 
AS
BEGIN
declare @max int ,@id nvarchar(50)
declare cur_rows cursor local
 for select title,count(*) from dbo.Save_Data group by title 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 dbo.Save_Data where title=@id
   fetch cur_rows into  @id ,@max  
   end
 close cur_rows
 set rowcount 0
END

你可能感兴趣的:(删除)