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

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

    You can do this simply with SSMS. Just go to your table name and expand the Triggers node to view a list of triggers associated with that table. Right click to modify your trigger. enter image description here

    0 讨论(0)
  • 2020-12-13 18:12
    select so.name, text
    from sysobjects so, syscomments sc
    where type = 'TR'
    and so.id = sc.id
    and text like '%YourTableName%'
    

    This way you can list out all the triggers associated with the given table.

    0 讨论(0)
  • 2020-12-13 18:12

    use sp_helptrigger to find the triggerlist for the associated tables

    0 讨论(0)
  • 2020-12-13 18:12

    you can open your trigger with sp_helptext yourtriggername

    0 讨论(0)
  • 2020-12-13 18:14

    Go through

    Need to list all triggers in SQL Server database with table name and table's schema

    This URL have set of queries by which you can get the list of triggers associated with particular table.

    I believe you are working in sqlserver following are the steps to get modify triggers

    To modify a trigger

    1. Expand a server group, and then expand a server.

    2. Expand Databases, expand the database in which the table containing the trigger belongs, and then click Tables.

    3. In the details pane, right-click the table on which the trigger exists, point to All Tasks, and then click Manage Triggers.

    4. In Name, select the name of the trigger.

    5. Change the text of the trigger in the Text field as necessary. Press CTRL+TAB to indent the text of a SQL Server Enterprise Manager trigger.

    6. To check the syntax of the trigger, click Check Syntax.

    0 讨论(0)
  • 2020-12-13 18:15

    Try to Use:

    select * from sys.objects where type='tr' and name like '%_Insert%'
    
    0 讨论(0)
提交回复
热议问题