Trigger Status

  • How do I tell if a trigger is currently enabled or disabled?

  • use OBJECTPROPERTY, ExecIsTriggerDisabled property name.

    that is...

    select OBJECTPROPERTY (OBJECT_ID ('trigger_name'), 'ExecIsTriggerDisabled')

    which returns

    1 = True

    0 = False

    HTH

    Billy

  • Try this script...

    selecto2.name as

    ,

    o1.name as [trigger],

    case

    when OBJECTPROPERTY ( object_id(o1.name ),'ExecIsInsteadOfTrigger') = 1 then 'Instead Of'

    when OBJECTPROPERTY ( object_id(o1.name ),'ExecIsAfterTrigger') = 1 then 'After'

    end as [Trigger Type],

    case OBJECTPROPERTY ( object_id(o1.name ),'ExecIsDeleteTrigger')

    when 1 then 'Yes'

    else 'No'

    end as [On Delete],

    case OBJECTPROPERTY ( object_id(o1.name ),'ExecIsInsertTrigger')

    when 1 then 'Yes'

    else 'No'

    end as [On Insert],

    case OBJECTPROPERTY ( object_id(o1.name ),'ExecIsUpdateTrigger')

    when 1 then 'Yes'

    else 'No'

    end as [On Update],

    case OBJECTPROPERTY ( object_id(o1.name ),'ExecIsTriggerDisabled')

    when 1 then 'No'

    else 'Yes'

    end as [Enabled]

    fromsysobjects o1

    joinsysobjects o2

    on(o1.parent_obj = o2.id)

    where o1.type = 'TR'

  • Hey, nice script. Thanks a lot.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply