【发布时间】:2018-01-23 16:09:17
【问题描述】:
我需要在实际上部分是 xml 的文本字段中找到一个子字符串。我尝试将其转换为 xml,然后使用 .value 方法,但无济于事。
我要查找的元素(子字符串)是一个方法名称,如下所示:
AssemblyQualifiedName="IPMGlobal.CRM2011.IPM.CustomWorkflowActivities.ProcessChildRecords,
“ProcessChildRecords”末尾的方法可以是另一个名称,例如“SendEmail”。我知道我可以使用“CustomWorkflowActivities.”和,(逗号)来查找子字符串(方法名称),但不知道如何完成它。此外,**"CustomWorkflowActvities.<method>"** 的实例可能不止一个列出
一些说明:
以下是我的原始查询。它返回每行中的第一次出现,但没有额外的。例如,我可能在字符串 '...IPM.CustomWorkflowActivities.ProcessChildRecords...' 和 '...IPM.CustomWorkflowActivities.GetworkflowContext...'
当前查询只返回Approve Time Process, ipm_mytimesheetbatch, ProcessChildRecords
SELECT WF.name WFName,
(
SELECT TOP 1 Name
FROM entity E
WHERE WF.primaryentity = E.ObjectTypeCode
) Entity,
Convert(xml, xaml) Xaml,
SUBSTRING(xaml, Charindex('CustomWorkflowActivities.', xaml) + Len('CustomWorkflowActivities.'), Charindex(', IPMGlobal.CRM2011.IPM.CustomWorkflowActivities, Version=1.0.0.0', xaml) - Charindex('CustomWorkflowActivities.', xaml) - Len('CustomWorkflowActivities.'))
FROM FilteredWorkflow WF
其中 1 = 1 AND xaml LIKE '%customworkflowactivities%' AND statecodename = '激活' AND typename = '定义' 按名称订购
【问题讨论】:
-
请指定哪些 RDBM
-
查看 RDBMS 中的
LIKE运算符。此外,许多 RDBMS 具有正则表达式匹配功能。但是,它并不快,因为无法使用该字段的索引。 -
实际的字段内容是什么?你是如何尝试提取字符串的?你想做什么?