搜索特定存储过程中特定单词的出现次数



如何通过下面的代码查找两个单词(michael|Kuldeep),

declare @word varchar(128)
set @word = (michael|Kuldeep)
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 '%' + @word + '%' 
and type = 'P'
and name = 'MenuDetailsSelect'
order by 
name

我要找的是使用正则表达式

找到两个名字

我可以通过使用下面的代码来完成我的目标

declare @word1 varchar(128)
set @word1 = 'Michael'
select name, (len(object_definition(object_id)) -  len(replace(object_definition(object_id), @word1, ''))) / len (@word1) as Michael
from sys.procedures
where object_definition(object_id) like '%'+@word1+'%' and type = 'P'
AND name='MenuDetailsSelect'
declare @word2 varchar(128)
set @word2 = 'Kuldeep'
select name, (len(object_definition(object_id)) -  len(replace(object_definition(object_id), @word2, ''))) / len (@word2) as Raveena
from sys.procedures
where object_definition(object_id) like '%'+@word2+'%' and type = 'P'
AND name='MenuDetailsSelect'

试图将其作为一个查询。

相关内容

  • 没有找到相关文章

最新更新