SQLLawman

Family man and SQL Geek

Find all Triggers

By MichaelDeputy, 1 year ago

I was asked to find all tables in a database that had a DML trigger so a developer could ensure that all the old functionality was available in the new database.  So once I built my query to give me the information, I thought I'd save it here for future use.

select a.name as 'Trigger', b.name as 'Table'
from sysobjects a
join sysobjects b
on a.parent_obj=b.id
where a.xtype = 'TR'

This gave me a nice little result set of each trigger and what table it was associated.  Maybe I won't have to re-invent the wheel the next time they ask.

1 comment

Gravatar #1. SQLRockstar
1 year ago

funny, i just put together some t-sql for finding triggers as well:

SELECT name, OBJECT_NAME(parent_id), is_disabled as [Parent Object] FROM sys.triggers

i use sys.triggers because it includes DDL triggers, which are not in the sysobjects table.

Write a comment

If you want to add your comment on this post, simply fill out the next form:





Anti-Spam Protection by WP-SpamFree

* Required fields

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>.

No trackbacks

To notify a mention on this post in your blog, enable automated notification (Options > Discussion in WordPress) or specify this trackback url: http://​www.deputyfamily.net/​MichaelDeputy/​archive/​2009/​08/​find-all-triggers/​trackback/