This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing an important TSQL Script to find the different status like Enable, Disable of a SQL Server Database Trigger.
Database Trigger is a significant object because it is doing the operation in the background and manipulates defined DDL and DML commands.
As a Database Administrator, this is our responsibility to find out the different status of all running Trigger of a SQL Server Database.
Below is a script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
SELECT [T].[name] AS TableName ,[TR].[name] AS TriggerName ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsTriggerDisabled') =1 THEN 'DISABLED' ELSE 'ENABLED' END) AS TriggerStatus ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsInsertTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsInsertTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsFirstInsertTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsFirstInsertTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsLastInsertTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsLAStInsertTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsDeleteTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsDeleteTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsFirstDeleteTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsFirstDeleteTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsLastDeleteTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsLAStDeleteTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsUpdateTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsUpdateTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsFirstUpdateTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsFirstUpdateTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsLastUpdateTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsLAStUpdateTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsAfterTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsAfterTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsInsteadOfTrigger') =1 THEN 'No' ELSE 'Yes' END) AS IsInsteadOfTrigger ,(CASE WHEN OBJECTPROPERTY([TR].[object_id], 'ExecIsTriggerNotForRepl') =1 THEN 'No' ELSE 'Yes' END) AS IsTriggerNotForReplication FROM sys.tables AS T INNER JOIN sys.triggers AS TR ON [T].[object_id]=[TR].[parent_id] |