利用存储过程来消除数据库中冗余的数据 create procedure sp_mytest as declare @pro varchar(50) declare @mm int declare wu cursor for select distinct product from mytest open wu fetch next from wu into @pro while @@fetch_status=0 begin select @mm=sum([cost]) from mytest where [product][email protected] delete from mytest where [product][email protected] insert into mytest ([product],[cost]) values(@pro,@mm)
fetch next from wu into @pro end close wu deallocate wu go 我们可以使用作业进行相应的数据的更新