Search

2015년 12월 22일 화요일

[Database] [MSSQL] 데이터베이스에 있는 모든 트리거(Trigger) 정보 보기.

* 현재 데이터베이스의 모든 트리거에 대한 정보를 가져오는 쿼리이다.
* 출처 : http://stackoverflow.com/questions/4305691/need-to-list-all-triggers-in-sql-server-database-with-table-name-and-tables-sch

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' 

댓글 없음:

댓글 쓰기