首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sqlserver 2008 触发器,对象名 'dbo.inserted' 无效?解决方案

2012-04-07 
sqlserver 2008 触发器,对象名 dbo.inserted 无效???建了一个触发器if exists (select 1from sysobjects

sqlserver 2008 触发器,对象名 'dbo.inserted' 无效???
建了一个触发器
if exists (select 1
  from sysobjects
  where id = object_id('T_accountingsubject')
  and type = 'TR')
  drop trigger T_accountingsubject
go


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

执行时提示
消息 208,级别 16,状态 1,第 3 行
对象名 'dbo.inserted' 无效。


这是怎么回事,难道2008没了inserted 和deleted表?


[解决办法]

SQL code
if exists (select 1  from sysobjects  where id = object_id('T_accountingsubject')  and type = 'TR')  drop trigger T_accountingsubjectgocreate trigger T_accountingsubject on 表名for/after/instead of insertasif 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)endgo更正如上 

热点排行