我需要使用SQL Server 2008从下面的字符串中获取第三个子字符串。
string1: -
('C20080703115333MCTTtettett','24','6101349328','Bundled Standard','4','2.00','Testing Insert for New SP',','PD2013021002584832540')
期望的结果: - 6101349328
string2: -
('C20080703115333MCTTetew','24','7101349328','Bundled Standard','4','2.00','Testing Insert for New SP',','PD2013021002584832540')
期望的结果: - 7101349328
STRING3: -
('C20080703115333MCTTteetew','24tt','8101349328','Bundled Standard','4','2.00','Testing Insert for New SP',','PD2013021002584832540')
期望的结果: - 8101349328
串,4: -
('C20080703','24','111101349328','Bundled Standard','4','2.00','Testing Insert for New SP',','PD2013021002584832540')
期望的结果: - 111101349328
提前致谢。
答案 0 :(得分:0)
尝试这样的事情:
select val = substring
(
str
, charindex(',', str, charindex(',',str, 0) + 1) + 2
, charindex(',', str, charindex(',', str, charindex(',',str, 0) + 1) + 1)
- (charindex(',', str, charindex(',',str, 0) + 1) + 3)
)
from strings
给出了:
6101349328
7101349328
8101349328
111101349328