通过查询,我得到了这个字符串 "Order::Resource(PPP32#BB300320LQ00J#AAAR05504)"
。
我想提取 # 字符之前、之间和之后的字符串,如下所示:
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, @start+@end+1, len(@string)-(@start+@end+1))
关于sql - 如何从sybase中的字符串中提取子字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12174448/