一个DML触发器的的例子
CREATE TRIGGER TR_DML
BEFORE
DELETE OR INSERT OR UPDATE
ON table_name
--其他操作
end TR_DML;
意思是在删除或插入或更新table_name这张表之前执行其他操作
一个简单的触发器
Create trigger [dbo].[tri_employee_insert]
on [dbo].[employee] after insert
as
begin
declare @dno varchar(3)
select @dno=dno from inserted
update department set dcount=dcount+1 where dno=@dno
end;