创建一个SQL Server 触发器?
发布网友
发布时间:2023-09-14 16:42
我来回答
共2个回答
热心网友
时间:2024-07-18 16:36
大体格式,你可以自己修改,重在理解思路!!
Create Trigger tr_CardConsumeDetail
On CardConsumeDetail
for Update ,insert
As
begin
Update CardConsumeDetail
Set currentScore ='要实现的更新'
From CardConsumeDetail c ,Deleted d ,Inserted i --Deleted和Inserted临时表
Where c.id=i.id
update Card
Set score='要实现的更新'
from Card c, Deleted d ,Inserted i
where c.id=i.id
end
热心网友
时间:2024-07-18 16:36
create trigger trigger_CardConsumeDetail
on CardConsumeDetail
for insert
as
declare @CONSTRAINT varchar(50)
select @CONSTRAINT =CONSTRAINT from inserted
update CardConsumeDetail set currentScore=新值 where CONSTRAINT =@CONSTRAINT
update Card set score=新值 where where CONSTRAINT =@CONSTRAINT