通过查询我得到这个字符串"Order::Resource(PPP32#BB300320LQ00J#AAAR05504)"
。 我想之前提取字符串之间和#字符后如下:如何从sybase中的字符串提取子字符串?
ID = PPP32
sub_id = BB300320LQ00J
SUP_ID = AAAR05504
有谁知道如何做到这一点?
通过查询我得到这个字符串"Order::Resource(PPP32#BB300320LQ00J#AAAR05504)"
。 我想之前提取字符串之间和#字符后如下:如何从sybase中的字符串提取子字符串?
ID = PPP32
sub_id = BB300320LQ00J
SUP_ID = AAAR05504
有谁知道如何做到这一点?
这里是正确的解决方案:
declare @string varchar(50)
select @string = 'Order::Resource(PPP32#BB300320LQ00J#AAAR05504)'
declare @start int, @end int, @secondstring varchar(100)
select @start = charindex('#',@string)
select @secondstring = substring(@string, @start+1, len(@string))
select @end = charindex('#',@secondstring)
select substring(@string,charindex('(', @string)+1, @start-1-charindex('(', @string)),
substring(@string,@start+1,@end-1),
substring(@string, @[email protected]+1, len(@string)-(@[email protected]+1))
[如何获得在Sybase列值,其中此列坐落在一个查询是另一个查询中的一部分吗?(HTTP的
最后一个包含')'。什么是不正确的? – itro
@itro纠正! :) –
declare @start int, @end int, @secondstring varchar(100)
select @start = charindex('#',@string)
select @secondstring = substring(@string, @start+1, len(@string))
select @end = charindex('#',@secondstring)
select substring(@string,1, @start-1),
substring(@string,@start+1,@end-1),
substring(@string, @[email protected]+1, len(@string)[email protected])
可能重复: //stackoverflow.com/questions/12173470/how-to-get-part-of-the-column-value-in-sybase-where-this-column-situated-in-a-qu) –