if exists (select 1
from sysobjects
where id = object_id('T_accountingsubject')
and type = 'TR')
drop trigger T_accountingsubject
go
create trigger T_accountingsubject on 表名
for/after/instead of insert
as
begin
if exists(select 1 from inserted) and not exists(select 1 from deleted)
begin
update accountingsubjects set isend=0 where id in(select parentid from inserted)
end
end
go
if exists (select 1
from sysobjects
where id = object_id('T_accountingsubject')
and type = 'TR')
drop trigger T_accountingsubject
go
create trigger T_accountingsubject on 表名
for/after/instead of insert
as
if exists(select 1 from inserted) and not exists(select 1 from deleted)
begin
update accountingsubjects set isend=0 where id in(select parentid from inserted)
end
go
更正如上
分享到:
相关推荐
理解sql触发器理解sql触发器理解sql触发器
SQL触发器使用实例 --创建触发器,示例1 /* 创建触发器[T_INSERT_卷烟库存表],这个触发器较简单。 说明: 每当[卷烟库存表]发生 INSERT 动作,则引发该触发器。 触发器功能: 强制执行业务规则,保证插入的数据...
解密SQL触发器、存储过程、函数,本人用过,可以用
获取SQL触发器的状态,是启用还是停用,业务系统有时候停用了触发器,可以用此检测
SQL触发器的使用及语法,简单易懂才是真
SQL触发器实例讲解.pdf
SQL触发器语法参考
SQL触发器的实例,初学SQl触发器很有用 SQL触发器的实例,初学SQl触发器很有用
SQL触发器实例讲解(20211008070418).pdf
SQL触发器的使用方法,SQL触发器的使用方法,SQL触发器的使用方法,SQL触发器的使用方法
SQL触发器应用实例(Delphi+数据库)..rar
SQL触发器实例讲解
比方说建了一张表,其中的两列为‘是否会员’和‘金额’,金额根据是否会员来定的,比如说如果是会员,则金额为500,不是会员则金额为1000,怎么在这个表上建立触发器,
在SQL Server里面也就是对某一个表的一定的操作,触发某种条件,从而执行的一段程序。触发器是一个特殊的存储过程。 常见的触发器有三种:分别应用于Insert , Update , Delete 事件。 我为什么要使用触发器?...
触发器是一种特殊的存储过程,在用户试图对指定的表执行指定的数据修改语句时自动执行。
SQL触发器.sql
SQL触发器实例讲解.doc SQL触发器实例讲解.doc SQL触发器实例讲解.doc
SQL触发器操作.sql 数据库操作的最好说明书