这个
sysobjects.{instrig/deltrig/updtrig}
instead of
请记住
条目
deltrig公司
sysobjects.deltrig column description
:
deltrig: Stored procedure ID of a delete trigger if the entry is a table. Table ID if the entry is a trigger
系统约束
sysconstraints.constrid
对象id(>触发器名称<)
),使用
sysconstraints.status
指定触发器是否用于插入、更新和/或删除的列(位图)。
使用示例代码(并替换
s1
markp
),这应该会让你知道自己面对的是什么:
select id,
left(name,30) as objname,
type,
left(user_name(uid),10) as 'owner',
deltrig,
instrig,
updtrig
from sysobjects
where name like 'tblAll%'
order by type,uid
go
id objname type owner deltrig instrig updtrig
----------- ------------------------------ ---- ---------- ----------- ----------- -----------
752002679 tblAllTypesTriggers_6 TR dbo 736002622 0 0
816002907 tblAllTypesTriggers_6 TR markp 736002622 0 0
736002622 tblAllTypesTriggers U dbo 0 752002679 0
-- here we see the 2x triggers (type = TR) have deltrig = 736002622 = id of the table (type = U)
select * from sysconstraints where tableid = object_id('tblAllTypesTriggers')
go
colid constrid tableid error status spare2
------ ----------- ----------- ----------- ----------- -----------
0 816002907 736002622 0 1024 0
-- here we see markp's trigger (constrid = 816002907) is associated with
-- the dbo's table (tableid = 736002622), with status & 1024 = 1024
-- indicating that this is a 'insert' trigger
注意:您可以从
.(“嗯,马克!”?)[是的,默认值
sp\U帮助触发器
可以从一些编辑中受益,例如,显示每个触发器的所有者/模式。]
回答您的问题时,请快速回答我的问题:
select left(o1.name,30) as tabname,
left(user_name(o1.uid),10) as tabowner,
left(o2.name,30) as trigname,
left(user_name(o2.uid),10) as trigowner
from sysobjects o1,
sysobjects o2
where o1.name = 'tblAllTypesTriggers'
and o1.type = 'U'
and o2.deltrig = o1.id
and o2.type = 'TR'
order by 1,2,4,3
go
tabname tabowner trigname trigowner
------------------------------ ---------- ------------------------------ ----------
tblAllTypesTriggers dbo tblAllTypesTriggers_6 dbo
tblAllTypesTriggers dbo tblAllTypesTriggers_6 markp
系统对象
系统约束
以及