`
freellf
  • 浏览: 8405 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

sql 触发器

阅读更多
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

更正如上

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics