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

后端 未结 14 1502
日久生厌
日久生厌 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:16

    You Can View All trigger related to your database by below query

    select * from sys.triggers
    

    And for open trigger you can use below syntax

    sp_helptext 'dbo.trg_InsertIntoUserTable'
    
    0 讨论(0)
  • 2020-12-13 18:17

    find triggers on table:

    select so.name, text
    from sysobjects so, syscomments sc
    where type = 'TR'
    and so.id = sc.id
    and text like '%TableName%'
    

    and you can find store procedure which has reference of table:

    SELECT Name
    FROM sys.procedures
    WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%yourtablename%'
    
    0 讨论(0)
提交回复
热议问题