Skip to content

Programmatically retrieve the trigger definition

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 programmatically.

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

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *