[英]Parse String with Multiple Delimiters
I have a field (call it Reporting_Hierarchy
) with a value like:我有一个字段(称为Reporting_Hierarchy
),其值如下:
Accounting: NorthAmerica: AP: Accounts Payable
I want to create a new field, based off of Reporting_Hierarchy
, that only takes the text after the third colon.我想创建一个基于Reporting_Hierarchy
的新字段,它只接受第三个冒号之后的文本。 In this case, that would = Accounts Payable
在这种情况下,这将 = Accounts Payable
What is the recommended way to do this?推荐的方法是什么? I have tried combinations of RIGHT/LEFT with charindex() but I am not getting exactly what I want.我尝试了 RIGHT/LEFT 与 charindex() 的组合,但我没有得到我想要的。 I know REGEX is also an option, but not sure if that is the easiest route here.我知道 REGEX 也是一种选择,但不确定这是否是这里最简单的路线。
You can use split_part()
:您可以使用split_part()
:
select split_part(Reporting_Hierarchy, ':', 4)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.