Use the stored procedure to eliminate data redundancy in the database

xiaoxiao2021-03-06  50

Using the stored procedure in the database to eliminate redundant data 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 = 0begin select @ mm = sum ([COST]) from mytest where [product] = @ pro Delete from mytest where [product] = @ pro INSERT INTOMTEST ([Product], [COST]) VALUES (@ pro, @ mm) fetch next from wu inTo @ ProendClose wudeallocate Wugo We can use jobs to update

转载请注明原文地址:https://www.9cbs.com/read-91164.html

New Post(0)