Situatie
Mai jos este o procedura ce listeaza toate obiectele de tip trigger de pe o baza a unui server MSSQL, iar pentru fiecare trigger afiseaza informatii despre tabela pe care este definit acel trigger, tipul de trigger, statusul lui, etc.
Solutie
create procedure FindTriggers
as
SELECT table_name = OBJECT_NAME(parent_object_id) ,
trigger_name = name ,
trigger_owner = USER_NAME(schema_id) ,
OBJECTPROPERTY(object_id, ‘ExecIsUpdateTrigger’) AS IsUpdate ,
OBJECTPROPERTY(object_id, ‘ExecIsDeleteTrigger’) AS IsDelete ,
OBJECTPROPERTY(object_id, ‘ExecIsInsertTrigger’) AS IsInsert ,
OBJECTPROPERTY(object_id, ‘ExecIsAfterTrigger’) AS IsAfter ,
OBJECTPROPERTY(object_id, ‘ExecIsInsteadOfTrigger’) AS IsInsteadof ,
CASE OBJECTPROPERTY(object_id, ‘ExecIsTriggerDisabled’)
WHEN 1 THEN ‘Disabled’
ELSE ‘Enabled’
END AS TrriggerStatus
FROM sys.objects
WHERE type = ‘TR’
ORDER BY OBJECT_NAME(parent_object_id)
Leave A Comment?