Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql来查找字符串中的字符_Sql_Substring_Charindex - Fatal编程技术网

Sql来查找字符串中的字符

Sql来查找字符串中的字符,sql,substring,charindex,Sql,Substring,Charindex,我有如图所示的字符串,我需要获取“INTERNAL_INSTRUCTION_NUM”旁边的值,这意味着我需要获取表INTERNAL_INSTRUCTION_NUM中值为9076的值“9076”。我需要从字符串中检索。放在里面的星号是我从字符串中需要的那个。我需要将参数作为INTERNAL_instruction_NUM传递,并将值返回为“9076” 字符串附加在下面的链接中。 这是一个SQL Server版本: declare @param nvarchar(max) = N'INTERNAL_

我有如图所示的字符串,我需要获取“INTERNAL_INSTRUCTION_NUM”旁边的值,这意味着我需要获取表INTERNAL_INSTRUCTION_NUM中值为9076的值“9076”。我需要从字符串中检索。放在里面的星号是我从字符串中需要的那个。我需要将参数作为INTERNAL_instruction_NUM传递,并将值返回为“9076”

字符串附加在下面的链接中。

这是一个SQL Server版本:

declare @param nvarchar(max) = N'INTERNAL_INSTRUCTION_NUM';

declare 
    @pos int,
    @temp nvarchar(max);

set @pos = charindex(@param, @test);

set @temp = substring(@test, @pos + len(@param), len(@test) 
                 - @pos - len(@param));

-- find first # after param
set @pos = charindex('#', @temp);
set @temp = substring(@temp, @pos+1, len(@temp) - @pos);

-- find second # after param
set @pos = charindex('#', @temp);
set @temp = substring(@temp, @pos+1, len(@temp) - @pos);

-- find the value we are looking for assuming it is enclosed between ",+" and "?%"
select substring(@temp, 3, len(@temp) - 4)

无法附加字符串。将下面的下拉框用于字符串附加的文本文件。似乎是特定于产品的问题。你用的是哪种数据库管理系统?你试过什么吗?你用的是哪种数据库管理系统?博士后?神谕DB2?火鸟?