Monday, August 20, 2012

SQL SERVER – How to find all trigger in a database?

Run the following script to get the all trigger in a database-

SELECT SO1.[name] Table_Name, SO2.[name] Trigger_Name,
CASE
WHEN SO1.deltrig = SO2.id  THEN 'Delete'
WHEN SO1.instrig = SO2.id THEN 'Insert'
WHEN SO1.updtrig = SO2.id THEN 'Update'
END 'TriggerType' , 'SO2',SO2.*,'SO1',SO1.*

FROM sysobjects SO2 JOIN sysobjects SO1
ON SO2.parent_obj = SO1.[id]
WHERE SO2.xtype='TR'

--or –-


SELECT * FROM SYSOBJECTS  WHERE XTYPE ='TR'

Output:

There are many columns which not showing on this snap shot. To see please run above query on SSMS.


Like and Share to SQL Integrity Blog

No comments:

Post a Comment

Thank You !!!!