1>
a:2{s:8:"folderid";s:28:"0B2cFhOMCK2KEOVBzbnZOczZsNkU";s:10:
"foldertext";s:17:"Home Health Files";}
2 - ;
a:2{s:8:"folderid";s:28:"0B2cFhOMCK2KEOVBzbnZOczZsNkU";s:10:
"foldertext";s:12:"Agency Files";}
3>
a:2{s:8:"folderid";s:28:"0B2cFhOMCK2KEMVB4SGFtVmozamc";s:10:"foldertext";s:9:"Dover HHC";}
我需要上述字符串中的文件夹名称,即Home Health Files
和Agency Files
,Dover HHC
。
,最后一个用""括起来的子字符串;
答案 0 :(得分:1)
试试这个:
DECLARE @role VARCHAR(4000) = 'a:2{s:8:"folderid";s:28:"0B2cFhOMCK2KEOVBzbnZOczZsNkU";s:10:"foldertext";s:17:"Home Health Files";}'
SELECT SUBSTRING(@role,LEN(@role)-CHARINDEX('"',REVERSE(@role),CHARINDEX('"',REVERSE(@role),0)+1)+2,(LEN(@role)-CHARINDEX('"',REVERSE(@role),0)-1)-(LEN(@role)-CHARINDEX('"',REVERSE(@role),CHARINDEX('"',REVERSE(@role),0)+1)))