利用存储过程

【字号: 日期:2024-02-19浏览:58作者:雯心
利用存储过程来消除数据库中冗余的数据CREATE PROCEDURE sp_mytest ASdeclare @pro varchar(50)declare @mm intdeclare wu Cursor for select distinct product from mytestopen wufetch next from wu into @prowhile @@fetch_status=0beginselect @mm=sum([cost]) from mytest where [product]=@prodelete from mytest where [product]=@proinsert into mytest ([product],[cost]) values(@pro,@mm)fetch next from wu into @proendclose wudeallocate wuGO我们可以使用作业进行相应的数据的更新
相关文章: