在nText字符串中搜索Vaule后查找下一个10个字符 [英] Find Next 10 Characters After the Search Vaule in a nText string
问题描述
我试图在ntext字段中找到我的搜索条件后面的10个字符。
I am trying to find the next 10 characters after my search criteria in a ntext field.
我是首先将ntext转换为varchar(max),并且可以找到我正在寻找的字符串的第一部分(URL),但接下来的10个字符都是不同的...我需要找到这个的下一个10个字符网址字符串。
I am first converting the ntext to a varchar(max) and can find the first part of a string (an URL) that I am looking for, but the next 10 characters are all different...I need to find these next 10 characters of this URL string.
示例:
我找到了我的价值:'% https://express.domain.com %'
I find my value: '%https://express.domain.com%'
但现在我想抓住' https://express.domain.com/abcdefghij '
最后10个字符都不同,所以我不能在SQL中使用类似的搜索。
The last 10 characters are all different so I can not use a like search in SQL.
有什么想法吗?
谢谢!
推荐答案
DECLARE @url varchar(max)= 'https://express.domain.com/abcdefghij';
$
SELECT SUBSTRING(@url,CHARINDEX('com /',@ url)+ 4,10);
DECLARE @url varchar(max) = 'https://express.domain.com/abcdefghij';
SELECT SUBSTRING(@url, CHARINDEX('com/', @url) + 4, 10);
这篇关于在nText字符串中搜索Vaule后查找下一个10个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!