如何知道哪些触发器被禁用?

如何得到目前数据库中有哪些触发器被禁用了?

---------------------------------------------------------------

将trigger 在sysobjects 表中 status字段的值转换为二进制的,第12位为1则表示禁止,为0表示允许

create function convert1(@a int)
returns varchar(100)
as
begin
declare @b varchar(100)
set @b=''
while @a<>0
select @b=@b+rtrim(@a%2),@a=@a/2
return @b
end

select name,case when substring(dbo.convert1(status),12,1)=1 then '禁用' else '启用' end from sysobjects
where type='tr'

---------------------------------------------------------------

--既然是第12位是禁用/启用标志,这样写简单一点吧

select 表名=object_name(parent_obj),触发器名=name
,状态=case status & power(2,11) when 0 then '启用' else '禁用' end
from sysobjects
where type='TR'

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus