62,046
社区成员
发帖
与我相关
我的任务
分享
ALTER TRIGGER [dbo].[triggerUpdateProduct]
ON [dbo].[p_product]
AFTER UPDATE
AS
IF UPDATE(SQuota) --判断更新该字段才处理
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @temp int
declare @status int
declare @quota decimal
declare @quota1 decimal
declare @productid int
declare @ProductType int
declare @id int
select @temp=i.Mid,@status=i.Status,@quota=i.SQuota,@productid=i.ProductID,@ProductType=i.ProductType,@quota1=d.SQuota from inserted i,deleted d where i.ProductID=d.ProductID
IF @quota<>@quota1 --更新的值不一样才更新
UPDATE m_member SET p1=@quota,d1=@quota1 where PID=@temp
END