Click here to Skip to main content
12,631,365 members (30,929 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.4K views
8 bookmarked
Posted

Programitically retrieve the trigger definition

, 19 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
I ran into this strange situation where I wanted to get Trigger Definition(the SQL content) of a specific trigger from a database. The following SQL query can used to retrieve the trigger definition programitically.SELECT DB_NAME() AS DataBaseName, dbo.SysObjects.Name AS...
I ran into this strange situation where I wanted to get Trigger Definition(the SQL content) of a specific trigger from a database. The following SQL query can used to retrieve the trigger definition programitically.

SELECT     
	DB_NAME() AS DataBaseName,					
	dbo.SysObjects.Name AS TriggerName,
	dbo.sysComments.Text AS SqlContent
FROM 
	dbo.SysObjects INNER JOIN 
		dbo.sysComments ON 
		dbo.SysObjects.ID = dbo.sysComments.ID
WHERE   
	(dbo.SysObjects.xType = 'TR') 
	AND 
	dbo.SysObjects.Name LIKE 'YourTriggerName'

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Manas Bhardwaj
Architect
Netherlands Netherlands
Read my personal blog at www.manasbhardwaj.net.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 19 Jan 2010
Article Copyright 2010 by Manas Bhardwaj
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid