1

各テーブルに関連付けられたトリガーのリストを取得するにはどうすればよいですか?

私はこのようなものを取得しようとしています:

Table 1 – Trigger for Table 1 – Trigger for Table 1 – Trigger for Table 1

Table 2 – Trigger for Table 2 – Trigger for Table 2 – Trigger for Table 2

データを簡単に解釈できる限り、この形式である必要はありません。

4

2 に答える 2

2

これを試してみてください -

SELECT 
      object_name = s.name + '.' + o.name
    , trigger_name = t.name
    , o.type_desc
    , is_insert_trigger = OBJECTPROPERTY(t.[object_id], 'ExecIsInsertTrigger')
    , is_update_trigger = OBJECTPROPERTY(t.[object_id], 'ExecIsUpdateTrigger') 
    , is_delete_trigger = OBJECTPROPERTY(t.[object_id], 'ExecIsDeleteTrigger')
    , t.is_instead_of_trigger
    , t.is_disabled
FROM sys.objects o WITH (NOWAIT) 
JOIN sys.schemas s WITH (NOWAIT) ON o.[schema_id] = s.[schema_id]
JOIN sys.triggers t WITH (NOWAIT) ON o.[object_id] = t.parent_id
WHERE o.[type] = 'U'
于 2013-04-12T08:37:14.910 に答える
1
SELECT 
 sysobjects.name AS trigger_name 
,USER_NAME(sysobjects.uid) AS trigger_owner 
,s.name AS table_schema 
,OBJECT_NAME(parent_obj) AS table_name 
,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate 
,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete 
,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert 
,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter 
,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof 
,OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') AS [disabled] 
FROM sysobjects 

INNER JOIN sysusers 
ON sysobjects.uid = sysusers.uid 

INNER JOIN sys.tables t 
ON sysobjects.parent_obj = t.object_id 

INNER JOIN sys.schemas s 
ON t.schema_id = s.schema_id 

WHERE sysobjects.type = 'TR'

お役に立てれば

于 2013-04-12T08:36:49.283 に答える