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

后端 未结 19 925
再見小時候
再見小時候 2020-11-28 17:12

I need to list all triggers in SQL Server database with table name and table\'s schema.

I\'m almost there with this:

SELECT trigger_name = name, trig         


        
19条回答
  •  -上瘾入骨i
    2020-11-28 18:15

    Use This Query :

        SELECT     
            DB_NAME() AS DataBaseName,  
            S.Name AS SchemaName,               
            T.name AS TableName,
            dbo.SysObjects.Name AS TriggerName,
            dbo.sysComments.Text AS SqlContent,
        FROM dbo.SysObjects 
        INNER JOIN dbo.sysComments ON dbo.SysObjects.ID = dbo.sysComments.ID
        INNER JOIN sys.tables AS T ON sysobjects.parent_obj = t.object_id 
        INNER JOIN sys.schemas AS S ON t.schema_id = s.schema_id 
        WHERE dbo.SysObjects.xType = 'TR' 
            AND dbo.SysObjects.Name LIKE 'Permit_AfterInsert' ---- <----- HERE
    

提交回复
热议问题