Where would you like to go, Toady? RSS 2.0
# Wednesday, July 21, 2010
When you open a SQL Server database that has Triggers, it is not at all obvious how you might find them and enumerate their contents. The following SQL code will show you all the triggers in your database including which table they are associated with.
SELECT name AS 'Trigger Name', OBJECT_NAME(parent_obj) AS 'Table'
FROM sysobjects
WHERE xtype = 'TR'

The results will be in this format.

Trigger result

 

From here, you can enumerate their contents like this

sp_helptext TriggerName

You can also view all the triggers associated with a particular table with this code.

sp_helptrigger TableName
Wednesday, July 21, 2010 1:21:25 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Bookmark, Tweet, or Share

OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Stackoverflow.com Rep
Flickr stream
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Chris Ballance
Sign In
Statistics
Total Posts: 46
This Year: 12
This Month: 0
This Week: 0
Comments: 11
All Content © 2010, Chris Ballance

Valid XHTML 1.0 Transitional