I'm upgrading a big 3rd party app to SQL Server 2000, and I need to loop through every trigger on a database and look for a certain keyword in the trigger's script. Any ideas?
select a.name, b.colid, b.text
from sysobjects a , syscomments b
where a.id = b.id
and a.type = 'TR'
and b.text like '%<key word value>%'
order by a.name, b.colid
syscomments table stores the text of the procedures/triggers in multiple rows for the same object. In a row it stores a maximum of 4000 characters. So colid will indicate the corresponding section of the code. This will not work if the triggers have been encrypted. If you only need a list of triggers then you can use the following query instead.
select a.name
from sysobjects a
where a.type = 'TR'
and exists (select * from syscomments b
where a.id = b.id
and b.text like '%<key word value>%')
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.