go
CREATE TRIGGER 数量统计 ON [dbo].[A1]
FOR INSERT
AS
declare @a int , @b int
select @a=0,@b=0
select @a =count(*) from inserted
select @b = 统计 FROM C1 --这里的赋值不对
where 名称 =' A '
SET @a = @a +@b
INSERT INTO D
VALUES(@a)
UPDATE C
SET 数量 = @a
where 名字 ='A'
可以创建如下类似触发器create trigger depart_update on depart for update
as
begin
if update(deptno)
begin
update worker set deptno = b.deptno from inserted b where worker.col1 = b.col1
end
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)