我想获取最后一个索引。
示例。
"Hello, World~! this is a sample"
我将搜索“ this”。
结果为4(此索引->'s')
答案 0 :(得分:0)
以下查询应执行您想要的操作:
DECLARE @text VARCHAR(100) = '"Hello, World~! this is a sample"'
DECLARE @ser VARCHAR(50) = 'this'
SELECT LEFT(REVERSE(SUBSTRING(@text,CHARINDEX(@ser,@text),LEN(@ser))),1)