篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MS SQL在DB中获取所有触发器相关的知识,希望对你有一定的参考价值。
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],
CASE OBJECTPROPERTY([so].[id],
'ExecIsTriggerDisabled')
WHEN 1 THEN 'Disabled'
ELSE 'Enabled'
END AS status
FROM sysobjects AS [so]
INNER JOIN sysobjects AS so2 ON so.parent_obj = so2.Id
WHERE [so].[type] = 'TR'
-- SOURCE: https://stackoverflow.com/a/4307260
以上是关于sql MS SQL在DB中获取所有触发器的主要内容,如果未能解决你的问题,请参考以下文章