How to find all trigger associated with a table with SQL Server?

后端 未结 14 1507
日久生厌
日久生厌 2020-12-13 17:46

I created a trigger for a table in SQL Server and it works for me.

My problem is: How do find it and modify it?

I use this query to find my triggers

14条回答
  •  北海茫月
    2020-12-13 18:01

    This might be useful

    SELECT 
     t.name AS TableName,
     tr.name AS TriggerName  
    FROM sys.triggers tr
    INNER JOIN sys.tables t ON t.object_id = tr.parent_id
    WHERE 
    t.name in ('TABLE_NAME(S)_GOES_HERE');
    

    This way you just have to plugin the name of tables and the query will fetch all the triggers you need

提交回复
热议问题