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:
select * from sys.triggers
This find all triggers, but how to open it and change the triggers?
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:
select * from sys.triggers
This find all triggers, but how to open it and change the triggers?
 
    
     
    
    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.
 
    
     
    
    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
 
    
    select m.definition from sys.all_sql_modules m inner join  sys.triggers t
on m.object_id = t.object_id 
Here just copy the definition and alter the trigger.
Else you can just goto SSMS and Expand the your DB and under Programmability expand Database Triggeres then right click on the specific trigger and click modify there also you can change.
 
    
    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%'
 
    
     
    
    select   B.name 
from     sys.objects    A
join     sys.triggers   B
on     A.object_id    =    B.parent_id
where    A.name    ='Table_name' /*Table Name*/
 
    
    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
Expand a server group, and then expand a server.
Expand Databases, expand the database in which the table containing the trigger belongs, and then click Tables.
In the details pane, right-click the table on which the trigger exists, point to All Tasks, and then click Manage Triggers.
In Name, select the name of the trigger.
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.
To check the syntax of the trigger, click Check Syntax.
 
    
     
    
    With this query you can find all Trigger in all tables and all views.
    ;WITH
        TableTrigger
        AS
        (
            Select 
                Object_Kind = 'Table',
                Sys.Tables.Name As TableOrView_Name , 
                Sys.Tables.Object_Id As Table_Object_Id ,
                Sys.Triggers.Name As Trigger_Name, 
                Sys.Triggers.Object_Id As Trigger_Object_Id 
            From Sys.Tables 
            INNER Join Sys.Triggers On ( Sys.Triggers.Parent_id = Sys.Tables.Object_Id )
            Where ( Sys.Tables.Is_MS_Shipped = 0 )
        ),
        ViewTrigger
        AS
        (
            Select 
                Object_Kind = 'View',
                Sys.Views.Name As TableOrView_Name , 
                Sys.Views.Object_Id As TableOrView_Object_Id ,
                Sys.Triggers.Name As Trigger_Name, 
                Sys.Triggers.Object_Id As Trigger_Object_Id 
            From Sys.Views 
            INNER Join Sys.Triggers On ( Sys.Triggers.Parent_id = Sys.Views.Object_Id )
            Where ( Sys.Views.Is_MS_Shipped = 0 )
        ),
        AllObject
        AS
        (
            SELECT * FROM TableTrigger
            Union ALL
            SELECT * FROM ViewTrigger
        )
    Select 
        * 
    From AllObject
    Order By Object_Kind, Table_Object_Id 
 
    
     select o1.name as trigger_name,o2.name as table_name from sys.objects o1 
 join sys.objects o2 on 
 o1.parent_object_id=o2.object_id     
 where o1.type='TR' 
 and o2.name='my_table'
 
  
 
    
    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'
 
    
     
    
    Much simple query below
select (select [name] from  sys.tables where [object_id] = tr.parent_id ) as TableName ,*  from sys.triggers tr
 
    
     
    
    select t.name as TriggerName,m.definition,is_disabled 
from sys.all_sql_modules m 
inner join  
sys.triggers t
on m.object_id = t.object_id 
inner join sys.objects o
on o.object_id = t.parent_id
Where o.name = 'YourTableName'
This will give you all triggers on a Specified Table
 
    
    Try to Use:
select * from sys.objects where type='tr' and name like '%_Insert%'
