SQL Server Admin
T-SQL Articles

August 28, 2010

Display DDL Triggers in your SQL Server Database




To display DDL Triggers in your database (SQL Server 2005/2008), use the sys.triggers catalog view as shown below:

-- Database-scoped DDL triggers in the current database
SELECT name as TriggerName, create_date as CreationDate,
type_desc as [TriggerType(SQLorCLR)], is_disabled
FROM sys.triggers
WHERE parent_class_desc = 'DATABASE'
ORDER BY name

The query shown above displays all the database-scoped triggers.

image

In order to view the server-scoped triggers, use the sys.servertriggers and sys.server_trigger_events

-- Server-scoped triggers in the current database
SELECT name as TriggerName, create_date as CreationDate,
st.type_desc [TriggerType(SQLorCLR)], is_disabled
FROM sys.server_triggers st
INNER JOIN sys.server_trigger_events ste ON
st.object_id = ste.object_id

You can also check a related post Display DML Triggers in your SQL Server Database


Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter



 
  Feedback:

comments

3 Responses to "Display DDL Triggers in your SQL Server Database"
  1. David G said...
    August 31, 2010 10:01 PM

    Very helpful. Is there a different way to display DML triggers or the code remains the same?

  2. Suprotim Agarwal said...
    August 31, 2010 10:24 PM

    David: Good question. Yes DML trigger require a different query. I will write a post soon. Thanks.

  3. Suprotim Agarwal said...
    September 2, 2010 2:53 AM

    David: Here's the query to display DML Trigger

    Display DDL Triggers in your SQL Server Database

 

Copyright © 2009-2011 All Rights Reserved for SQLServerCurry.com by Suprotim Agarwal | Terms and Conditions