不能编辑触发器!报如下错误!
[SQL-DMO]名称“deltype”在triggers集合中找不到!如果该名称是限定名,请使用[]分割名称的各部分,然后再试!
我的代码如下:
create trigger [delType]
on [TypeTable]
for delete
as
if ((select parentID from deleted )> 0 )
update TypeTable
set typeChildren = typeChildren - 1,
endTag = 0
where typeID in (select parentID from deleted )
GO
运行显示成功执行,在表下也能看到新建的触发器!
但就是要再编辑的时候总是报上面的错误!
------解决方案--------------------try
if exists(select 1 from sysobjects where xtype= 'TR ' and name= 'delType ')
drop trigger delType
go
create trigger [delType]
on [CMS].dbo.[TypeTable]
for delete
as
if ((select parentID from deleted )> 0 )
update TypeTable
set typeChildren = typeChildren - 1,
endTag = 0
where typeID in (select parentID from deleted )
GO