MS SQL获取所有触发器

列出所有触发器以及其所属表:

 

SELECT
    [so].[name] AS [trigger_name],
    USER_NAME([so].[uid]) AS [trigger_owner],
    USER_NAME([so2].[uid]) AS [table_schema],
    OBJECT_NAME([so].[parent_obj]) AS [table_name],
    OBJECTPROPERTY([so].[id], 'ExecIsUpdateTrigger') AS [isupdate],
    OBJECTPROPERTY([so].[id], 'ExecIsDeleteTrigger') AS [isdelete],
    OBJECTPROPERTY([so].[id], 'ExecIsInsertTrigger') AS [isinsert],
    OBJECTPROPERTY([so].[id], 'ExecIsAfterTrigger') AS [isafter],
    OBJECTPROPERTY([so].[id], 'ExecIsInsteadOfTrigger') AS [isinsteadof],
    OBJECTPROPERTY([so].[id], 'ExecIsTriggerDisabled') AS [disabled] 
FROM sysobjects AS [so]
INNER JOIN sysobjects AS [so2] ON (so.[parent_obj] = so2.[Id])
WHERE [so].[type] = 'TR'
Source Code

 

posted @ 2020-12-24 15:07  Insus.NET  阅读(238)  评论(0编辑  收藏  举报