更新时间:2023-02-22 12:04:10
问题是子字符串参数的第二部分包含第一个索引.您需要从第二个索引中减去第一个索引才能完成这项工作.
The problem is that the second part of your substring argument is including the first index. You need to subtract the first index from your second index to make this work.
SELECT SUBSTRING(@Text, CHARINDEX('the dog', @Text)
, CHARINDEX('immediately',@text) - CHARINDEX('the dog', @Text) + Len('immediately'))