Jeg ville bruge object_definition
funktion
og sys.procedures
se
på denne måde:
declare @word varchar(128)
set @word = 'place'
select name, (len(object_definition(object_id)) - len(replace(object_definition(object_id), @word, ''))) / len (@word) as qty
from sys.procedures
where object_definition(object_id) like '%'[email protected]+'%' and type = 'P'
order by name
Tilføjet efter kommentar, alle forekomster af specifikke ord i alle lagrede procedurer:
declare @word varchar(128)
set @word = 'place'
select sum((len(object_definition(object_id)) - len(replace(object_definition(object_id), @word, ''))) / len (@word)) as qty
from sys.procedures
where object_definition(object_id) like '%'[email protected]+'%'
Her er et fungerende (og opdateret efter kommentar) eksempel:http://sqlfiddle.com/#! 3/a759c/7