在 SQL Server 中从下面的字符串中获取倒数第二个单词

问题描述 投票:0回答:1

我试图在 SQL Server 的下面的字符串中从右边找到倒数第二个词。

Declare @text as varchar(60)

Set @text = 'Next Generation Customer Service'

我希望输出为“客户”

有人可以帮忙吗? 提前致谢。

我尝试使用 charindex、reverse 等

sql-server string word right-to-left
1个回答
-1
投票
Declare @text as varchar(60)

Set @text = 'Next Generation Customer Service'

select substring( @text, charindex('Customer',@text),len('Customer'))
© www.soinside.com 2019 - 2024. All rights reserved.