删除触发器
create trigger tri_delete
on student
for delete
as
declare @student_id varchar(10)
select @student_id=student_id from deleted
if @student_id='admin'
begin
raiserror('错误',16,8)
rollback tran
end
插入触发器
CREATE TRIGGER tee ON [dbo].[a]
FOR INSERT
AS
declare @z nvarchar(22)
select @z= aa from inserted
insert into b values(@z,@z)
更新触发器
CREATE TRIGGER [sa NAME] ON [dbo].[a]
FOR UPDATE
AS
declare @z nvarchar(22)
if update(aaa)
begin
select @z=aaa from inserted
insert into b values(@z,@z)
end
注:在更新触发器中 inserted 表示新更新的行,deleted表示更新前的行